DateDiffSQL
4 min
returns an integer value in the same units as the datepart parameter the return value is the result of subtracting the second date and time from the first date and time this function behaves the same as the microsoft sql function called datediff this function uses the boundary crossing method to calculate the date difference, while the diff functions (such as diffdays, diffminutes, diffyears, and so on) use the whole interval method see date functions docid\ kqs 9orcyllvh63bboyqv for more information about using the boundary crossing method versus using the whole interval method syntax datediffsql(datepart, firstdatetime, seconddatetime, timezone) enabled for for a description of the business object categories, see notes on "enabled for" docid\ u26v9fecfs6ilwa0 pvjd business object category yes/no business rules before save rules yes business rules calculation rules (after save, with or without also recalculate on load) yes business rules calculation rules (before save or always, without also recalculate on load) yes business rules calculation rules (before save or always, with recalculate on load) yes business rules editing rules yes business rules initialization rules yes business rules read only rules yes business rules required rules yes business rules validation rules yes client expressions yes object permissions yes services yes ldap yes mobile yes quick actions (except ui quick actions) yes ui quick actions yes reports yes search/dashboard without field references yes search/dashboard with field references yes parameters parameter description datepart the interval type must be surrounded by quotes (" ") the following interval types are supported millisecond second minute hour day week month quarter year firstdatetime the first date and time to be compared seconddatetime the second date and time to be compared timezone (optional) the time zone, in iana format return value number value if the firstdatetime parameter is before the seconddatetime parameter, the returned value is positive if the firstdatetime parameter is after the seconddatetime parameter, the returned value is negative (this is the opposite of the datediff() function ) example to calculate the weekday of a given date within a quick action, you can use $(datediffsql("day", "2012 1 1 12 00 am", tostring(currentdate()) % 7) +1) this results in 1 for sunday, 2 for monday, and so on
