DATE_TRUNC

functionsupportedCore SQL functions

docs.snowflake.com ↗

Date & time functions

Truncates a DATE, TIME, or TIMESTAMP value to the specified precision. For example, truncating a timestamp down to the quarter returns the timestamp corresponding to midnight of the first day of the original timestamp’s quarter. This function provides an alternative syntax for TRUNCATE, TRUNC by reversing the two arguments. Truncation is not the same as extraction. For example: - Truncating a timestamp down to the quarter using this function returns the timestamp corresponding to midnight of the first day of the quarter for the input timestamp. - Extracting the quarter date part from a timestamp using the Extract function returns the quarter number of the year in the timestamp.

Syntax

DATE_TRUNC( <date_or_time_part>, <date_or_time_expr> )

Parameters

NameRequiredDescription
date_or_time_partrequiredThis argument must be one of the values listed in Supported date and time parts.
date_or_time_exprrequiredThis argument must evaluate to a date, time, or timestamp.

Returns

The returned value is the same type as the input value. For example, if the input value is a TIMESTAMP, then the returned value is a TIMESTAMP.

Usage notes

See also

Referenced by