IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Date that will be 6 months less than the current date


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Superior Member


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

PostPosted: Mon Dec 08, 2008 4:16 pm
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
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: 2
Location: india

PostPosted: Mon Dec 22, 2008 1:07 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Changeman - how can we know the curr... Compuware & Other Tools 2
Search our Forums:

Back to Top