Monthly ?

FredJason

New Member
hi, Can anyone help. i have a problem about month function. this is the scenario. i want to generate a report every 29 of month, and it will last in 5 years. how do i get the succeeding month? i try this code.. for 1 year only.

DEFINE VARIABLE reportdate AS DATE NO-UNDO.
DEFINE VARIABLE resultdate AS DATE NO-UNDO.
DEFINE VARIABLE ctr AS INTEGER NO-UNDO.

reportdate = 1/29/11.


DO ctr = 1 TO 12:
reportdate = reportdate + 30.
MESSAGE reportdate
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.

i need the output like this..
01/29/11 03/01/11 03/29/11 04/29/11 05/29/11 06/29/11 07/29/11 08/29/11 09/29/11 10/29/11 11/29/11 12/29/11
 
Am not sure what you are trying to do exactly, but based on what you have asked and my understanding here is my sample code:

Code:
DEFINE VARIABLE daDate AS DATE        NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER     NO-UNDO.
DEFINE VARIABLE chDateRange AS CHARACTER   NO-UNDO.

ASSIGN
    daDate = DATE(1,29,2011).

DO iLoop = 1 TO (5 * 12):

     chDateRange = chDateRange + STRING( ADD-INTERVAL(daDate,iLoop,'months'),'99/99/9999') + ' '.

END.

MESSAGE chDateRange
    VIEW-AS ALERT-BOX INFO.
Note when using the ADD-INTERVAL function it will automatically handle leap years. So for example the date 29th Feb 2011 will be round down to the 28th Feb 2011.
 
Back
Top