View previous topic :: View next topic
|
Author |
Message |
Naga Rajender.K
New User
Joined: 19 Dec 2008 Posts: 13 Location: Hyderabad
|
|
|
|
Hi,
I want to perfrom arithmetic operations on two dates and agin i need to get a date in result.
Code: |
05 WS-DATE-1.
10 WS-DD-1 PIC X(02).
10 FILLER PIC X(01) VALUE "/".
10 WS-MM-1 PIC X(02).
10 FILLER PIC X(01) VALUE "/".
10 WS-YYYY-1 PIC X(04).
05 WS-DATE-2.
10 WS-DD-2 PIC X(02).
10 FILLER PIC X(01) VALUE "/".
10 WS-MM-2 PIC X(02).
10 FILLER PIC X(01) VALUE "/".
10 WS-YYYY-2 PIC X(04). |
i want to:
COMPUTE WS-DATE = WS-DATE-1 - WS-DATE-2
(I this this won't work.For this will i use intrinsic functions?i.e do i need to required format to use in intrinsic functions)
IF WS-DATE-1 > WS-DATE-2
do some thing
ELSE
do something
END-IF
(Is this ok. Can i do this without formating)
Please help me out.
Thanks in advance |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
As specified, 31/01/2000 would compare larger than 01/05/2009. As long as this is what you want, your IF statement is fine.
You'll need to use INTEGER-OF-DATE to convert dates into integers before adding and subtracting -- or you can go through the elaborate process of handling days, months, years separately. You will need to convert your date with slashes into YYYYMMDD format before invoking the function. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
(I this this won't work.For this will i use intrinsic functions?i.e do i need to required format to use in intrinsic functions) |
For instance:
argument-1
Must be an integer of the form YYYYMMDD
Quote: |
(Is this ok. Can i do this without formating) |
Not with the format DD/MM/YYYY, but you could if the format was YYYY/MM/DD. |
|
Back to top |
|
|
Naga Rajender.K
New User
Joined: 19 Dec 2008 Posts: 13 Location: Hyderabad
|
|
|
|
Thank you for quick reply. Is there any values clause for date arithmetic in DB2.
I got SELECT on SYSIBM.SYSDUMMY1 table. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you clarify your latest post.
Nearly everyone has "SELECT on SYSIBM.SYSDUMMY1 table" and the question before this is not clear. . . |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
In SQL, Date maths are limited. Check here for detailed information.
Maybe also look here to see some values to put after your SELECT.
For example (to calculate the first day of next month):
Code: |
SELECT
LAST_DAY(CURRENT DATE) + 1 DAY
INTO
:WS-BEG-NEXT-MO
FROM
SYSIBM.SYSDUMMY1
|
|
|
Back to top |
|
|
|