Skip to main content

Using Advanced Expressions: Date_Trunc

Distributor guide to the DATE_TRUNC advanced expression in Encompass Fusion reports: round a date back to the start of its year, month, week or day. Needs FusionEdit permission and v23.01+.

B
Written by Bailey Naas-Thornton

Minimum Version Required: 23.01

Pre-Conditions

  • Required Permission - FusionEdit
    ​
    ​

  • Recommended Fusion I/II Certification

Steps

Truncates a date, time, or timestamp to the specified part. Think of this as rounding back in time. Truncating to the week would give the first date of the week. Date Part examples: Year, Month, Week, Day, Hour, Minute, Second. NOTE: The database returns Monday as the beginning of the week and Sunday as the last day in the week.


​Syntax

DATE_TRUNC(Date or Time Part,Date/Time value)


​
​Arguments

Date or Time Part:

The keyword that will determine what you are trying to truncate your Date or Time field to be.


Date/Time value:

The Date or Time you want to truncate.


​
​Example

DATE_TRUNC(WEEK, '2019-02-01') = 1/28/2019
​
2/1/2019 is Friday
​
1/28/2019 is the Monday of that week.
​
​

DATE_TRUNC('YEAR', '2019-03-25') =2019-01-01
​
DATE_TRUNC('MONTH', '2019-03-25') =2019-03-01

Did this answer your question?