LAST_OF_PERIOD

Script Function: Determines the last day of period of a specified date

Syntax

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

Syntax

Description/Format

Date

Period Format

See Date, Time and Period Formats in Scripts.

Output Format

Format guidelines for the determined date.
Format: AE name, script literal or script variable
Default: YYMMDD  

Calendar

Name of the Calendar object which should be taken into account  for the period ending.
Format: AE name, script literal or script variable

Calendar Event

Name of the Calendar Event which should be taken into account for the period ending.
Format: AE name, script literal or script variable 


Return codes

Date of the period end in the specified format
"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

This script function determines the last day of the period to which a specified date belongs. The returned value is a date.

The script function is assigned a date. Optionally, you may specify a particular Date Format. The default Date Formats to be used are "YYMMDD" or "YYYYMMDD". A colon or semicolon may be used as a separator between Date Format and Date.

With Period Format, the type of period (year, quarter, month or week) is defined.
Note: There is a special period format "WS" for this function. That way Sunday is always taken as the first day of the week. "WW", however, takes Monday as the first day of the week.

Output Format is optional. If Output Format is not used, the script function returns the default format "YYMMDD" as the date. Please note: Commas are to be used when Output Format is not used but Calendar and Calendar Event are specified.

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 (e.g.: 0000-00-00).

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

Examples

The first example determines the last day of the week for the 03/29/2000. The result 02.04.00 (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 01.04.00 (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: