RPG – Legacy date processing

Convert numeric date DDMMYY to numeric date CCYYMMDD

w_num8 = %dec(%date(w_num6:*dmy):*iso);

Convert numeric date DDMMYY to data type “date”

w_date = %date(w_num6:*dmy);

Convert  numeric date CCYYMMDD to formatted string “dd/mm/ccyy”

date_string = %editw(%dec(%date(newRateDate:*iso):*eur):’  /  /    ‘);

Convert data type “date” to character

w_char10 = %char(w_date:*iso-);

Find number of months between two ”numeric” dates

diff = %diff(%date(incdat:*dmy):%date(iindt:*dmy):*m);

Check the year portion of a “numeric” date

If  %SubDt(%date(ndate):*Y) = 2005;
Eval wrktot = wrktot + namt;
EndIf;

Create timestamp using date & time
myTimeStamp = %date() + %time();

Create timestamp using timestamp BIF
myTimeStamp = %timestamp();

Convert timestamp variable to type date
myDate = %date(myTimeStamp);

Convert timestamp to numeric DDMMCCYY
myDDMMCCYY = %dec(%date(myTimeStamp):*eur);

Convert timestamp to numeric CCYYMMDD
myCCYYMMDD = %dec(%date(myTimeStamp):*iso);