to_timestamp
Converts UINT256 seconds since the Unix epoch to a timezone-naive TIMESTAMP. Interpret the result as UTC when the source value is an EVM block timestamp.
Example
Local
{"id":"sample_54pjvm","title":"Sample","code":"-- Interpret an EVM block timestamp as UTC\nSELECT to_timestamp(1700000000::UINT256)::VARCHAR AS block_time;\n-- => [{\"block_time\":\"2023-11-14 22:13:20\"}]"}
Notebook ready in readonly mode.
API reference
Exact signatures with descriptions, requirements, inputs, returns, and examples.
to_timestamp(UINT256) #
Converts unsigned Unix seconds to TIMESTAMP. Values above INT64_MAX return NULL; values within INT64 that exceed the supported TIMESTAMP conversion range can raise a Conversion Error.
Inputs
| Name | Type | Use |
|---|---|---|
unix_seconds | UINT256 UINT256 whole seconds since 1970-01-01 00:00:00. NULL returns NULL. | required positional |
Returns
| Name | Type |
|---|---|
timestamp | TIMESTAMP |
SQL timestamp. Returns a timezone-naive TIMESTAMP. Values above INT64_MAX return NULL; other out-of-range conversions may throw.
Examples
Local SQL
{"id":"sample_o1ub5z","title":"Sample","code":"-- A large timestamp that still converts successfully\nSELECT to_timestamp(253402300799::UINT256)::VARCHAR AS upper_example;\n-- => [{\"upper_example\":\"9999-12-31 23:59:59\"}]"}
Notebook ready in readonly mode.
Category and tags
- Category
- EVM utilities
- Tag
- Types
- Tag
- EVM