View previous topic :: View next topic
|
Author |
Message |
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
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 |
|
|
sandeep1dimri
New User
Joined: 30 Oct 2006 Posts: 76
|
|
|
|
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 |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
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 |
|
|
kgumraj
Active User
Joined: 01 May 2006 Posts: 151 Location: Hyderabad
|
|
|
|
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 |
|
|
karnataka
New User
Joined: 15 Sep 2006 Posts: 20 Location: bangalore
|
|
|
|
Thanks a lot... |
|
Back to top |
|
|
sagard
New User
Joined: 16 May 2007 Posts: 4 Location: Pune
|
|
|
|
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 |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
sagard, question was about 'given date' not about current date. |
|
Back to top |
|
|
|