Skip to main content

PQL46 (PQL Function Library - CPM 4.6)

WORKDAYS_BETWEEN

Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 CELONIS 4.5 CELONIS 4.6

Description

This function calculates working days between two dates based on a TFACS style calendar table.

The calendar table can be configured in the Data Model Editor and applies to all calls of WORKDAYS_BETWEEN in the Data Model.

The calendar table has to have the following layout:

  • Calendar ID: Identifier of the working calendar

  • Year: Year of the calendar

  • Month 1: Working days of January bit encoded. 1 is a working day. 0 is a day off. Example of January 2019 with the weekends off: 1111001111100111110011111001111

  • Month 2: Working days of February.

  • ...

  • Month 12: Working days of December

WORKDAYS_BETWEEN ( calendar_id, start, end )
  • calendar_id: the ID defines which calendar out of the calendar table is used.

If the calendar ID does not exist in the calendar table, WORKDAYS_BETWEEN behaves like the DAYS_BETWEEN function and returns the number of days between the specified dates.

To calculate the workdays between two dates without a calendar table, REMAP_TIMESTAMPS can be used.

Example

[1] Here WORKDAYS_BETWEEN is used without an existing working calendar. Therefore it returns the number of days between the specified dates.

Query

Column1

WORKDAYS_BETWEEN ( "Table1"."Calendar_ID" , "Table1"."Column1" , "Table1"."Column2" )

Input

Output

Table1

Column1 : DATE

Column2 : DATE

Calendar_ID : STRING

Sat Apr 15 2017 00:00:00.000

Sun Apr 16 2017 00:00:00.000

'Calendar ID that does not exist'

Sun Apr 16 2017 00:00:00.000

Mon Apr 17 2017 00:00:00.000

'Calendar ID that does not exist'

Mon Apr 17 2017 00:00:00.000

Tue Apr 18 2017 00:00:00.000

'Calendar ID that does not exist'

Result

Column1 : INT

1

1

1

See also: