Scalar function
NULL value yields NULL. For malformed non-NULL strings ANSI mode raises an error; non-ANSI mode yields NULL. Numeric overflow/non-finite conversions can raise errors.
Syntax
Scalar
Scaled (scalar)
- Use integer epoch values and a constant BIGINT scale; floating-point and decimal operands can select string-format handling instead of epoch scaling.
- Integer division by 10^scale discards the subsecond remainder.
- Both arguments must be constants. Numeric columns can raise an argument error, including with TRY variants.
Arguments
Scalar
Scaled
Returns
- Type: TIMESTAMP with timezone
- NULL behavior: NULL value yields NULL. For malformed non-NULL strings ANSI mode raises an error; non-ANSI mode yields NULL. Numeric overflow/non-finite conversions can raise errors.
Properties
Usage notes
- Parsed text keeps its time zone. If no time zone is present, UTC is used.
- When parsing several values together, the first parsed time zone can be applied to all results. Avoid mixing time zones in one input column.
- NULL explicit format raises an error.
- In the two-number form, scale must be an integer from 0 through 18. The value is divided by 10^scale to obtain whole seconds; any fractional second is discarded.
- Invalid-input behavior depends on the query’s ANSI mode. See the NULL and error rules above.
- INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.
Examples
Basic example
Convert a date to midnight
Limitations
- Use the format arguments shown here. Formats that vary by row are outside the forms covered on this page.
- The scaled form requires the constant integer arguments described above. Cast FLOAT, DOUBLE, or DECIMAL values to BIGINT explicitly before using them as epoch units.
Last modified on October 15, 2026