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

How to calculate 6 months previous date from the given date


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

PostPosted: Wed May 23, 2007 2:50 pm
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 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 Need to convert date format DFSORT/ICETOOL 20
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top