Ques Regarding Date in Iseries cobol.

555 pts.
Tags:
AS400 iseries
COBOL
PGM
Hi Group,
I have a date field declared as packed field of 9, and date is declared as mmddyyyy format. My requirement is such that i need to pick the date field and 1 day to it. For example if the date is '02142012' i need to add 1 day to it and end result should be '02152012'. If the date value is '01312012', after 1 day to it the result should be '02012012'. How to resolve this? I should go for an OPM cobol pgm or ILE cobol PGM?
Regards,
mvrkrishna


Software/Hardware used:
db2400, Iseries Cobol.

Answer Wiki

Thanks. We'll let you know when a new response is added.

I have not done COBOL for 25 years.
In RPG, you would convert that date from a packed filed to a date field.
Then use ADDDUR which would all you to add 1 day to the date.
Then put in pack in the packed field.

I’s sure it is the same in COBOL ILE.

Discuss This Question: 2  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
  • MDratwa
    Put the date as YYYYMMDD. WORKING-STORAGE SECTION. 01 WS-WRK-DATE FORMAT DATE '%Y%m%d'. 01 WS-DAYS PIC S9(05) COMP-3 VALUE 1. 01 WS-DATE PIC X(08). PROCEDURE DIVISION. MOVE WS-DATE TO WS-WRK-DATE . MOVE FUNCTION ADD-DURATION (WS-WRK-DATE DAYS WS-DAYS) TO WS-DATE. If you want to substract 1 day - change WS-DAYS to -1 and use: MOVE FUNCTION SUBTRACT-DURATION(WS-WRK-DATE DAYS WS-DAYS) TO WS-DATE
    785 pointsBadges:
    report
  • TomLiotta
    You can, of course, do old style date calculations in OPM COBOL (COBOL/400), but it's much easier in ILE COBOL. All you need to do is use REDEFINES to redefine your 9-digit packed variable as an appropriate DATE item. For example:
           01  W-Date                          pic s9(9)
                                                   packed-decimal
                                                   value 02152012.
           01  W-MMDDYYYY redefines W-Date     format date '%m%d@Y'
                                               usage packed-decimal.
    Now you can use the ADD-DURATION function:
               move   function add-duration ( W-MMDDYYYY days 1 )
                              to  W-MMDDYYYY
    Tom
    125,585 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