DateDiff (PQL)
Returns the difference between the 2 specified date-time values expressed by the date-part.
- Returned Output: Numeric
- Library: PQL \ Granular \ Date-Time
- Version: 2023.00.000
- Compatibility: Pyramid Query Language (PQL) data sources
Syntax
* Click on the function's arguments above for more details on the input values.
Comments
- The input columns need to both be attributes with date-time values in the model. (The data type needs to be 'date-time')
- The Flag is a text indicator describing what date / time units should be used to express the differential
- The resulting column is a numeric value - NOT a date or time.
- For details on how to employ and use this function see the custom column overview.
Flags
There are different flags that can be used to achieve the same outcome as shown below.
- Years
- year
- years
- yyyy
- yy
- Quarters
- quarter
- quarters
- qtr
- q
- Months
- month
- months
- mm
- m
- Weeks
- week
- weeks
- wk
- ww
- w
- Days
- day
- days
- dd
- d
- Hours
- hour
- hours
- hh
- Minutes
- minute
- minutes
- min
- mi
- Seconds
- second
- seconds
- ss
- s
Different Function types
- As a granular function, it is used in the base SQL query itself.
Examples
This example returns a column with the number of days between the order date and ship date.
DateDiff([transactions].[Order Date] ,[transactions].[Ship Date],"dd")
In the example below, the 5th column represents the day difference between the order date column (column 1) and ship column (column 2) using the formula above,