Kbase P132616: 4GL/ABL: How to programmatically calculate the last day of any month given its date?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  23/06/2008 |
|
Status: Unverified
GOAL:
4GL/ABL: How to programmatically calculate the last day of any month given its date?
GOAL:
How to get the last day of the month of a given date?
GOAL:
Sample User Defined Function (UDF) to get the last day of the month of a given date.
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1x
FIX:
The following code uses the ADD-INTERVAL and the DAY functions to create User Defined Function (UDF) named getLastDayOfMonth that calculates the last day of the month of its DATE input parameter. The code further gives examples how to use this function:
FUNCTION getLastDayOfMonth RETURNS DATE(INPUT ipdDate AS DATE) FORWARD.
MESSAGE
getLastDayOfMonth(TODAY) "~n"
getLastDayOfMonth(01/30/2003) "~n"
getLastDayOfMonth(12/30/2004)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
FUNCTION getLastDayOfMonth RETURNS DATE(INPUT ipddate AS DATE):
RETURN ADD-INTERVAL (ipddate, 1, 'Month') - DAY(ADD-INTERVAL (ipddate, 1, 'Month')).
END FUNCTION.