Last updated
Last updated
The DATE_TRUNC function truncates a timestamp expression or literal based on the date part that you specify, such as hour, day, or month.
().
In this function truncates a DATE, TIME, or TIMESTAMP value to the specified precision.
Valid in Snowflake:
microsecond, microseconds
millisecond, milliseconds
second, seconds
minute, minutes
hour, hours
day, days
week
month, months
quarter, quarters
year, years
Invalid formats in Snowflake:
Weeks
decade, decades
century, centuries
millennium, millennia
This transformation is performed in order to emulate Redshift behavior for the following date parts
decade, decades
century, centuries
millennium, millennia
For more information please refer to the following documentation in Snowflake:
In Amazon Redshift, the default precision for timestamps is 6 digits (microseconds), while in Snowflake, the default precision is 9 digits (nanoseconds). Due to these differences in precision, it’s important to consider your specific needs when working with timestamps. If you require different precision in either platform, you can use the following options.
Use ALTER SESSION:
Please note that depending on the data type used to store the value obtained with DATE_TRUNC(), there may be limitations in precision that could result in a loss of accuracy.
There are no known issues.
This function is fully supported in .
For more information about quoted identifiers in functions, .
2024-02-02 04:05:06.000000
2024-02-02 04:00:00.000000
2024-01-29 00:00:00.000000
2024-02-01 00:00:00.000000
2024-01-01 00:00:00.000000
2024-02-02 04:05:06.000000
2024-02-02 04:05:06.000
2024-02-02 04:00:00.000
2024-01-29 00:00:00.000
2024-02-01 00:00:00.000
2024-01-01 00:00:00.000
2024-02-02 04:05:06.000000
1990-01-29 00:00:00.000000
1990-01-01 00:00:00.000000
1901-01-01 00:00:00.000000
1001-01-01 00:00:00.000000
1990-01-29 00:00:00.000
1990-01-01 00:00:00.000
1901-01-01 00:00:00.000
1001-01-01 00:00:00.000
Date function