DateDiff

Returns the difference between the 2 specified date-time values expressed by the date-part.

  • Returned Output: Numeric
  • Library: PQL \ Common \ Date-Time
  • Version: 2018.00.000
  • Compatibility:
    • Can be combined with and other PQL function throughout the application.
    • It CANNOT be used with MDX or VBA functions. But it can be used on MDX-based content in other parts of the application.

Syntax

DateDiff( <Date-Time> , <Date-Time> , <Flag> )

* Click on the function's arguments above for more details on the input values.

Comments
  • The 2 date-time input values (representing the "from" and "to" dates) can be any elements that resolve to a date-time values.
  • The date-part flag needs to conform to the acceptable types described below.
  • The date-part flag must be enclosed in quotation marks " ".
  • This function is often used in conjunction with other date-time functions and operations

Date-Part flags

Date-part

Flags

Years

yyyy,yy,year

Quarters

qtr,q,quarter

Months

mm,m, month

Weeks

wk,ww,w,week

Days

dy, dayofyear

Hours

hh, hour

Minutes

min, mi, minute

Seconds

ss,s,second

Milliseconds

ms, millisecond

Examples

This example returns 2

DateDiff(CreateDate(2019, 4, 13), CreateDate(2017, 4, 13), "yyyy")

This example returns 365

DateDiff(CreateDate(2018, 6, 13), CreateDate(2017, 6, 13), "dy")

This example returns 24

DateDiff(CreateDate(2019, 4, 13), CreateDate(2019, 4, 14), "hh")