DateDiff - Built-in Date & Time Function¶
Purpose¶
DateDiff returns the interval between two dates.
Syntax¶
DateDiff(str, date1, date2)
Arguments¶
| Argument | Required | Description |
|---|---|---|
str |
Yes | One of the following letters, static or as a result of a valid expression |
date1 |
Yes | Any valid datetime expression |
date2 |
Yes | Any valid datetime expression |
Valid interval specifiers for str:
D— dayH— hourN— minuteS— second
Returns¶
Integer
See also¶
- Date
- DateAdd
- DatePart
- DateValue
- DateSerial
- Day
- Hour
- InAgedToDays
- InLast4WeeksToSunday
- InLast7Days
- InLastFullMonth
- InLastFullWeek
- InLastYearMTD
- InLastYearYTD
- InLeapYear
- Minute
- Month
- MonthName
- Now
- Second
- Time
- TimeSerial
- TimeValue
- WeekAgo
- Weekday
- WeekdayName
- Year
Example¶
// returns the number of days between current date and time and the stored
// order date and time
Return DateDiff ('D', now(), {OrderHeader.Order_Date})
Notes¶
- When the arguments cannot be converted to the specified type, a runtime error is generated.
- The order of the two date parameters is important for the result. If
date1is prior todate2, the result will be negative.