--- title: "dateDiff" description: "Calculates the difference between the two dates, returning the result as a floating point value in the units specified by field" --- # dateDiff > Calculates the difference between the two dates, returning the result as a floating point value in the units specified by field **This function is used by Ignition's Expression language.** ## Description Calculates the difference between the two dates, returning the result as a floating point value in the units specified by field, which must be a string matching one of these values: - ms - second - sec - minute - min - hour - hr - day - week - month - year The return value will be a floating point value, meaning that parts of units are considered. The exception to this rule is for the months and years fields, which will always return an integral difference. If the second date argument is after the first, the return value will be positive, otherwise it will be negative. ## Syntax `dateDiff(date1, date2, field)` ### Parameters | Type | Parameter | Description | |--------|-----------|-----------------------------------------------------------------------------| | Date | `date1` | The first date. | | Date | `date2` | The second date. | | String | `field` | The units for the difference. | ### Returns **Float** - The difference between the two dates in the units specified. ## Examples ```python title="Code Snippet" dateDiff(toDate("2008-2-24 8:00:00"), toDate("2008-2-24 8:15:30"), "minute") //returns 15.5 ``` ```python title="Code Snippet" dateDiff(toDate("2008-2-24 8:00:00"), toDate("2008-3-12 9:28:00"), "month") //returns 1.0 ``` ```python title="Code Snippet" dateDiff(toDate("2008-2-24 8:00:00"), toDate("2008-3-12 9:28:00"), "day") //returns 17.02 ```