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
 

 

How to calculate 6 months previous date from the given date

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

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Mon May 21, 2007 11:20 am    Post subject: How to calculate 6 months previous date from the given date
Reply with quote

hi,

can any body tell, how to calculate 6 months previous date from the given date.

eg: given-date => 12-12-2006
6 months-previous-date==>12-06-2006

Thanks .....
Back to top
View user's profile Send private message

sandeep1dimri

New User


Joined: 30 Oct 2006
Posts: 76

PostPosted: Mon May 21, 2007 11:25 am    Post subject:
Reply with quote

Hi

You can check your shop's library :-) as in every shop one can find date modules so why to recode the logic :-)

If you could not find it out then we will try for pseudeo code

Thanks
Sandeep
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Mon May 21, 2007 12:35 pm    Post subject: Re: date calculation
Reply with quote

Hi
Please check this one.


01 year1.
02 yy pic 9(4).
02 mm pic 99.
02 dd pic 99.

01 year2.
02 yy1 pic 9(4).
02 mm1 pic 99.
02 dd1 pic 99.

Procedure Division.

if mm > 6
move yy to yy1
move dd ti dd1
Compute mm1 = mm - 6
enf-if.

if mm < 7
Compute yy1 = yy - 1
move dd to dd1
Compute mm1 = mm + 6
end-if.

Display year2.


Aji Cherian
Back to top
View user's profile Send private message
kgumraj

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Mon May 21, 2007 10:42 pm    Post subject:
Reply with quote

Hi,

You can code with a query

Code:

EXEC SQL
         SELECT (:WS-DATE - 6 MONTHS)
         INTO :WS-DATE-MOD
         FROM SYSIBM.SYSDUMMY1
END-EXEC
Back to top
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Tue May 22, 2007 4:59 pm    Post subject:
Reply with quote

Thanks a lot...
Back to top
View user's profile Send private message
sagard

New User


Joined: 16 May 2007
Posts: 4
Location: Pune

PostPosted: Tue May 22, 2007 8:47 pm    Post subject:
Reply with quote

Following query should also work

EXEC SQL
SELECT (CURRENT DATE - 6 MONTHS)
INTO :WS-DATE-MOD
FROM SYSIBM.SYSDUMMY1
END-EXEC


'Current Date' is a db2 Special register which stores the current date.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed May 23, 2007 2:50 pm    Post subject:
Reply with quote

sagard, question was about 'given date' not about current date.
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 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
No new posts Date and time format in CICS Chandru3183 CICS 2 Sat Mar 18, 2017 12:46 pm
No new posts How to get current date -1 and curren... murali.andaluri DFSORT/ICETOOL 3 Wed Mar 08, 2017 2:09 pm


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