DATEDIFF
Syntax
DATEDIFF (interval, date1, date2)
Description
Returns the time difference between two specified dates where date1 is subtracted from date2.
Arguments
interval | A String representing a unit of time that can be: — yyyy = years — q = quarters — m = months — d = days — ww = weeks — h = hours — n = minutes — s = seconds |
date1 | The first date and time. |
date2 | The date and time to compare against. |
Returns
The time interval between the two specified dates expressed as an Integer32 value.
Remarks
DATEDIFF compares the entire date, including minutes and seconds, if available. Anything less than the next interval returns 0. For example:
DATEDIFF ("yyyy", "1/1/2016 12:01:00", "12/31/2016 12:59:59")
Returns 0 because this interval, while very close, is still less than a full year.
Example
The following example returns the number of months between the current UTC date and time and the DateTime value in the source field PurchaseDate. If the value in MyEntity.PurchaseDate is 6/5/2016 and the current UTC date and time is 12/02/2016 11:27:23 AM:
DATEDIFF ("m", MyEntity.PurchaseDate, GETCURRENTUTCTIME)
Returns: 5 because there are less than 6 full months in the interval.