LAST_OF_PERIOD

Use the LAST_OF_PERIOD script function to determine the last day of of the period to which a specified date belongs. The returned value is a date. A date is assigned to the script function.

Tip: Use the :ON_ERROR script statement to define action in case of an error. For more information, see Script Elements for Error Handling.

Syntax

LAST_OF_PERIOD ([Date Format:]Date, Period Format[, Output Format[, Calendar, Calendar Event]])

Parameters

  • LAST_OF_PERIOD
    Determines the last day of a period of a specified date
  • Date
  • Period Format
    Defines the type of period such as a year, quarter, month, or week)
    Note: There is the special period format "WS" for this function. This format defines Sunday as the first day of the week. The format "WW" defines Monday as the first day of the week. For details, see Date, Time and Period Formats in Scripts
  • Output Format
    (Optional) Format guidelines for the determined date. If this parameter is not used, the script function returns the default format "YYMMDD" as the date.
    Note: You must set commas if this parameter is not used, but if the Calendar and Calendar Event keys are defined.
    Format: AE name, script literal or script variable
    Default: YYMMDD
  • Calendar
    (Optional) Name of the Calendar object to be taken into account  for the ending period
    Format: AE name, script literal or script variable
    Note: If Calendar and Calendar Event are used, this script function returns the correct calendar day of the period. If there is no valid calendar day for this period, the result is a zero date in the respective date format such as 0000-00-00.
  • Calendar Event
    (Optional) Name of the Calendar Event to be taken into account for the ending period ending
    Format: AE name, script literal or script variable 
    Note: If Calendar and Calendar Event are used, this script function returns the correct calendar day of the period. If there is no valid calendar day for this period, the result is a zero date in the respective date format such as 0000-00-00.

Return codes

The date of the period end in the specified format is returned:

  • 20327
    The Calendar object does not exist
  • 20328
    The Calendar Event does not exist in the Calendar object
  • 20456
    The Calendar Event does not include the end date of the period

Examples

The first example determines the last day of the week for 03/29/2022. The result 03.04.22 (Sunday) is output in the activation report.

:SET &DATE#=LAST_OF_PERIOD ("000329","WW","DD.MM.YY")
:
PRINT &DATE#

With the special period format "WS", the date 02.04.22 (Saturday) is output in the activation report.

:SET &DATE#=LAST_OF_PERIOD ("DD.MM.YY:29.03.00","WS","DD.MM.YY")
:
PRINT &DATE#

In the third example, the first correct calendar day of a quarter is determined. The guidelines of an output format are not taken into account.

:SET &DATE#=LAST_OF_PERIOD ("000329", "Q", , READINESS, WEEKDAY)
:
PRINT &DATE#

See also: