Skip to main content

Using Advanced Expressions: DateDiff

Distributor guide to the DATEDIFF advanced expression in Encompass Fusion reports: count the days, weeks, months or years between two dates. 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

Calculates the difference between two date, time, or timestamp expressions based on the date or time part requested. The function returns the result of subtracting the second argument from the third argument. Keep the syntax as (Date Part, StartDate, EndDate) to get positive results. (Date Part, EndDate, StartDate) will give negative results.
​
Date Part examples: Year, Month, Week, Day.


​Syntax

DATEDIFF(Date or Time Part, StartDate, EndDate)


​
​Arguments

Date or Time Part:

A keyword to determine the "Diff" output. Use 'Day' to see the number of days. Use 'Week' to see the number of weeks. Use Minute to see the number of minutes. Etc. (You can only use Time parts for DateTime fields.)
​
​

StartDate:

This can be a Date or DateTime depending on which part you are using.
​
​

EndDate:

This can be a Date or DateTime depending on which part you are using.


​
​Examples

DATEDIFF(YEAR, '2019-01-01', '2020-01-05') = 1
​
DATEDIFF(MONTH, '2019-01-01', '2020-01-05') = 12
​
DATEDIFF(DAY, '2020-01-01', '2020-01-05') = 4
​
DATEDIFF(HOUR, '2020-01-01', '2020-01-05') = 96
​
DATEDIFF(MINUTE, '2020-01-01', '2020-01-05') = 5760
​
DATEDIFF(SECOND, '2020-01-01', '2020-01-05') = 345600

Did this answer your question?