Newer Version Available
date_diff()
Syntax
date_diff(datepart,startdate,enddate)
- year
- month
- quarter
- day
- week
- hour
- minute
- second
startdate specifies the start date.
enddate specifies the end date.
Usage
Returns the time difference between two dates in years, months, or days. For example,
date_diff("year", toDate("31-12-2015", "dd-MM-yyyy"), toDate("1-1-2016", "dd-MM-yyyy")) returns 1.
If startdate is after enddate the difference is returned as a negative number.You must use date_diff() in a foreach() statement. You cannot use this function in group by, order by, or filter statements.
Example - How Many Weeks Did Each Opportunity Take to Close?
Use date_diff() with datepart = week to calculate how long, in weeks, it took to close each opportunity.
Example - How Long Ago Was an Opportunity Closed?
Use date_diff() with datepart = month to calculate how many months have passed since each opportunity closed. Use now() as the end date.