Hi
I have converted the sys date to *CYMD format.I have two problems,
1.For eg 19/12/08 is now 1081219,where 1 stands for 2000-2050 and 0 stands for 1900 to 1999(defined in system).But i want to map this with dates in file whose format is 20081219.
2.If this is possible i need to subtract the date by 1 and then move to a dataarea.All done using CL.
Please suggest.
I have coverted to *cymd format.But sinde this is *char i will not be able to subtract from this.Can this be done only using julien...is there a way to subtract form the curren date
If you don't have TATOOLs with the ADDDAT command then yes
convert to Julian, subtract 1 from the day part, if day part is 0 then subtract one from the year part
and put the day part at 365 or 366 on leap year and convert to your desired date format.
CL converts from *dec to *char and back in the CHGVAR command. So you will need to
put the last three char of the julian into a *dec 3 variable using substring.
Thanks for the info...Is there a simpler process this one seems too elaborate...if not then i will proceed with ur suggestion.I dont have taatoll to use ADDDAT but if there are similar opcodes it could help
hI
i used the below code to get a day before current date.But this will not work on jan 1st and i have not handled for a leap year.
Can you please suggest..
PGM
DCL VAR(&CURDT) TYPE(*CHAR) LEN(6)
DCL VAR(&YYDDD) TYPE(*CHAR) LEN(5)
DCL VAR(&JULIAN) TYPE(*DEC) LEN(5 0)
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&CURDT)
CVTDAT DATE(&CURDT) TOVAR(&YYDDD) FROMFMT(*SYSVAL) +
TOFMT(*JUL) TOSEP(*NONE)
CHGVAR VAR(&JULIAN) VALUE(&YYDDD)
CHGVAR VAR(&JULIAN) VALUE(&JULIAN-1)
CHGVAR VAR(&YYDDD) VALUE(&JULIAN)
CVTDAT DATE(&YYDDD) TOVAR(&DATE) FROMFMT(*JUL) +
TOFMT(*SYSVAL) TOSEP(*NONE)
SNDPGMMSG MSG(&CURDT)
ENDPGM
Hey Phil
Thanks a lot...I was finally able to get it done with quite a bit of coding...one last question regarding this ...is there an opcode to check the factor of a number...can you explain how to build that condition...
No, of course not -- that would be too easy but I think this will work
since &FCT has zero decimals dividing by 4 would loose the fractional part
then multiply by 4 and compare with the original. If they are the same it's a leap
year -- unless it isn't -- see below!
dcl &FCT *dec 2 0
chgvar &FCT (&YYd/4)
chgvar &FCT (&FCT * 4)
if (&FCT = &YYd)
The year 2000 is a leap year. Some programs know about
this. They simply check whether a year is divisible
by 4, and hence conclude that 2000 is a leap year.
Or they are more rigorous and are aware of the exception:
a year that is divisible by 100 as well is
not a leap year, unless it is also divisible by 400. In
other words, neither 1900 nor 2100 are leap years,
but 2000 is.
So this code is good till 2100
Phil
Discuss This Question: 9  Replies