Converting julian date with CL on the AS400

135 pts.
Tags:
AS/400
CL
Can anyone help me with correcting the following code? I believe the error is in the /* CONVERT TO 30 DAYS AGO */ area, but I can't see it. ********************************************************************************* DCL &TODAY *CHAR 6 DCL &LESS30 *CHAR 6 DCL &MBRDATE *CHAR 5 DCL VAR(&MBRDAT2) TYPE(*DEC) LEN(5 0) /* CONVERT TODAY'S DATE TO JULIAN */ RTVSYSVAL SYSVAL(QDATE) RTNVAR(&TODAY) MONMSG CPF0000 CVTDAT DATE(&TODAY) TOVAR(&MBRDATE) FROMFMT(*SYSVAL) + TOFMT(*JUL) TOSEP(*NONE) MONMSG CPF0000 /* CONVERT TO 30 DAYS AGO */ CHGVAR VAR(&MBRDAT2) VALUE(&MBRDATE) CHGVAR VAR(&MBRDAT2) VALUE(&MBRDAT2-35) CHGVAR VAR(&MBRDATE) VALUE(&MBRDAT2) CVTDAT DATE(&MBRDATE) TOVAR(&LESS30) FROMFMT(*JUL) + TOFMT(*SYSVAL) TOSEP(*NONE) MONMSG CPF0000 SNDPGMMSG MSG('TODAY = ' *CAT &TODAY *CAT ', 35 DAYS + AGO = ' *CAT &LESS30) ADDLIBLE TAATOOL MONMSG CPF0000 /* CHANGE SBMJOB COMMAND BELOW TO DO ACTION(*DLT) AND OBJNAM(*ALL) WHEN */ /* READY TO IMPLEMENT */ SBMJOB CMD(TAATOOL/DLTIFS + OBJ('/E900SYS/PRINTQUEUE') + OBJNAM('*.XML') CRTDATE(&LESS30 *LT) + ACTION(*DLT)) JOB(DLTOLDPQUE) + JOBD(JDE) JOBQ(*LIBL/OPSJOBQ) MONMSG CPF0000 ENDPGM ******** 4 > call operations/dltoldpque Date not in specified format or date not valid. TODAY = 010913, 35 DAYS AGO = Library TAATOOL already exists in library list. Value ' ' for parameter CRTDATE not a valid date. Previous 1 errors found in embedded command DLTIFS. Error found on SBMJOB command.

Software/Hardware used:
AS400 V6R1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
     Today is 13008 subtract 35 is 12973 which is not the answer you wantBut if you have TAATOOL then you have ADDDAT,  ADDDAT will add or subtract and will do everything you want in a single step!
    49,435 pointsBadges:
    report
  • philpl1jb
    49,435 pointsBadges:
    report
  • TomLiotta
    There are a couple problems with the routine. First, it has a bunch of MONMSG CPF0000 commands throughout the code. All of those should either be removed or be replaced with useful MONMSG handlers.   But this statement is not logically valid: CHGVAR VAR(&MBRDAT2) VALUE(&MBRDAT2-35) It's okay mathematically, but the value is being used as a Julian date. And that makes the subtraction logically invalid. You can't be adding and subracting Julian date values and then using the resulting values as new Julian dates.   If you want to add/subtract a number of days to a date, you have to work with date durations or not use dates. See the Convert an *iso date to *longjul in CLP thread for one recent discussion.   Since you seem to have TAATOOLs, you can probably use one of those tools to do the math.   Tom
    125,585 pointsBadges:
    report
  • Rrbond07
    Thanks people. Yes, I did get the same result 12973 which is not correct. I've been away from CL for so long I've forgotten most of it. I will check out the ADDDAT and see what I can come up with. Further suggestions are always welcome!! Thanks!
    135 pointsBadges:
    report
  • Rrbond07
    Well, I've tried the ADDDAT and it gave me the results I wanted. From 011413 it subtracted 35 days that I wanted and gave me 121012. Now my next question, I want to delete all IFS entries with the extention having .xml. Using the date of 121012, I need to delete any .xml entires older than 121012. How would I do that using DLTIFS? Thanks for any help you can offer.
    135 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following