Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us