%DateTimeDiffExtended meta-SQL element

Syntax

%DateTimeDiffExtended(datetime_from, datetime_to, granularity, precision)

Description

The %DateTimeDiff meta-SQL function returns a numeric value, representing the difference between two date times. 

The granularity determines what that value represents:

  • DAYS or DAY — Difference in number of days.

  • HOURS or HOUR — Difference in number of hours.

  • MINUTES or MINUTE — Difference in number of minutes.

  • SECONDS or SECOND — Difference in number of seconds.

The precision specifies how many decimal places the result may have. The valid values are 0–5.

Example

The following two examples both return name of every batch process that is queued to be run in the next hour:

SELECT PRCSNAME FROM PSPRCSRQST WHERE RUNSTATUS = '5' AND %DateTimeDiffExtended(RQSTDTTM, %CURRENTDATETIMEIN, HOUR, 0) < 1;

SELECT PRCSNAME FROM PSPRCSRQST WHERE RUNSTATUS = '5' AND %DateTimeDiffExtended(RQSTDTTM, %CURRENTDATETIMEIN, MINUTE, 0) < 60;