week/isoweek functions

These functions return the corresponding week/isoweek from a timestamp. The timestamp must be supplied as an argument to the function.

Syntax:

INTEGER week(<timestamp>)

INTEGER isoweek(<timestamp>)

Semantics:

Note: If the argument is NULL or empty, the result is also NULL or empty.

Example 1 - Determine the week and ISO week number from a passenger’s travel date

SELECT
$s.fullName,
$s.contactPhone,
week(CAST($bagInfo.flightLegs[1].flightDate AS Timestamp(0))) AS TravelWeek,
isoweek(CAST($bagInfo.flightLegs[1].flightDate AS Timestamp(0))) AS ISO_TravelWeek
FROM baggageinfo $s, $s.bagInfo[] AS $bagInfo

Explanation: You first use CAST expression to convert the flightDate to a TIMESTAMP and then fetch the week and isoweek from the timestamp.

Output:

{"fullName":"Adelaide Willard","contactPhone":"421-272-8082","TravelWeek":7,"ISO_TravelWeek":7}

{"fullName":"Adam Phillips","contactPhone":"893-324-1064","TravelWeek":5,"ISO_TravelWeek":5}