Functions

DATEDIFF

Calculates the difference between two dates, returns the amount of time in the specified units (day, year, month etc.) between a start and end date.

Syntax

int? DATEDIFF(string part, DateTime? startdate, DateTime? enddate)

Input

Object Data Type Description
part String A string to represent the time unit (year,month,day,hour,minute,second).
startdate DateTime A start DateTime.
enddate DateTime An end DateTime value.

Example

DATEDIFF("month", DATEVALUE("2016-05-02"), DATEVALUE("2017-02-25"))

Will return '9' as there are nine months between the two dates.

or

DATEDIFF("day", TODAY(), CreatedDate)

Will return the difference in days between Today's date and the date stored in the CreatedDate field for each record.