Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Date that will be 6 months less than the current date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
meltingmemories

New User


Joined: 13 Oct 2008
Posts: 16
Location: Bangalore

PostPosted: Mon Dec 08, 2008 4:03 pm    Post subject: Date that will be 6 months less than the current date
Reply with quote

Hi,

I want to get a date that will be 6 months less than the current date in my cobol progam. Can you please help me out.
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Mon Dec 08, 2008 4:16 pm    Post subject:
Reply with quote

Hi,

Let's start with this - What did you try so far, what happened ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Dec 08, 2008 9:26 pm    Post subject:
Reply with quote

Also, you need to be more specific. 6 months ago, same day of the month? What about leap year?
Back to top
View user's profile Send private message
priya_d

New User


Joined: 06 Feb 2008
Posts: 3
Location: india

PostPosted: Mon Dec 22, 2008 1:07 pm    Post subject: Reply to: Date that will be 6 months less than the current d
Reply with quote

Meenakshi ,

U can use the following code..............



Code:
IF FORMAT-DATE-MM < 7                       
    SUBTRACT 1 FROM FORMAT-DATE-YY           
    ADD 12 TO FORMAT-DATE-MM                 
    IF FORMAT-DATE-YY = 00                   
        MOVE +99 TO FORMAT-DATE-YY           
        SUBTRACT 1 FROM FORMAT-DATE-CC       
    ELSE                                     
        SUBTRACT 1 FROM FORMAT-DATE-YY.     
                                             
SUBTRACT 6 FROM FORMAT-DATE-MM.             
                                             
IF  30-DAY-MONTH IN FORMAT-DATE-DATE         
    AND FORMAT-DATE-DD > 30                 
    MOVE 30 TO FORMAT-DATE-DD               
ELSE                                         
    IF  FEBRUARY IN FORMAT-DATE-DATE         
        IF  LEAP-YEAR IN FORMAT-DATE-DATE   
            AND FORMAT-DATE-DD > 29         
            MOVE 29 TO FORMAT-DATE-DD       
        ELSE                                 
            IF  FORMAT-DATE-DD > 28         
                MOVE 28 TO FORMAT-DATE-DD   



Where the date can be defined as :

Code:
05  FORMAT-DATE-DATE.
10  FORMAT-DATE-CC      PIC 9(2).
10  FORMAT-DATE-YY      PIC 9(2).                 
    88 LEAP-YEAR            VALUES 00 04 08 12 16
                                   20 24 28 32 36
                                   40 44 48 52 56
                                   60 64 68 72 76
                                   80 84 88 92 96.
10  FORMAT-DATE-MM      PIC 9(2).                 
    88 FEBRUARY             VALUE  02.           
    88 30-DAY-MONTH         VALUES 09 04 06 11.   
10  FORMAT-DATE-DD      PIC 9(2).                 


Hope this will help you.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am
This topic is locked: you cannot edit posts or make replies. Comparing current time with the time ... arunsoods SYNCSORT 1 Mon Oct 30, 2017 4:07 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us