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.
- The numeric value can be a column. A constant NULL value or NULL scale can raise a format-related error.
Arguments
Scalar
Scaled
Returns
- Type: TIMESTAMP with UTC 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
- Numeric values are epoch seconds; DATE values become midnight.
- 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