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: 685
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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am


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