trunc
function
Applies to: Databricks SQL Databricks Runtime
Returns a date with the date truncated to the unit specified by the format model unit
.
Notes
fmt
must be one of (case-insensitive):
'YEAR'
,'YYYY'
,'YY'
- truncate to the first date of the year that the date falls in.'QUARTER'
- truncate to the first date of the quarter that the date falls in.'MONTH'
,'MM'
,'MON'
- truncate to the first date of the month that the date falls in.'WEEK'
- truncate to the Monday of the week that the date falls in.
If fmt
is not well-formed the function returns NULL
.