********************************************************************** * TO COMPILE: * * CRTBNDRPG PGM(xxx/DATESTUFF2) SRCFILE(xxx/QRPGLESRC) * ********************************************************************* * This program demonstrates how to retrieve the current date, * how to add one month to the current date, how to subtract * one month from the current date, how to add 30 days to the * current date and how to subtract 30 days from the current date. * Lastly, the program will show how to find the last day of the * month for a given date. * ********************************************************************* H Datedit(*mdy) D Current_Date S 8 0 D WorkDate S D DATFMT(*USA) D Days S 2 0 /Free //Retrieve current date Current_Date = *Date; Dsply Current_Date; /End-Free * Move Current Date to WorkDate * Need fixed form syntax here because of the required MOVE operation C Move Current_Date WorkDate C WorkDate Dsply /Free //Add 1 Month to WorkDate using %Month BIF WorkDate = WorkDate + %Months(1); Dsply WorkDate; //Subtract 1 Month from WorkDate WorkDate = WorkDate - %Months(1); Dsply WorkDate; //Add 30 Days to WorkDate WorkDate = WorkDate + %Days(30); Dsply WorkDate; //Subtract 30 Days to WorkDate WorkDate = WorkDate - %Days(30); Dsply WorkDate; //Find the last day of the month for this date WorkDate = WorkDate + %Months(1); WorkDate = WorkDate - %Days(%SubDt(WorkDate:*Days)); Dsply WorkDate; *InLr = *On;