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
 

 

Arithmetic and Comparisions on dates

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

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Mon May 04, 2009 6:06 pm    Post subject: Arithmetic and Comparisions on dates
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Mon May 04, 2009 6:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Mon May 04, 2009 6:25 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Naga Rajender.K

New User


Joined: 19 Dec 2008
Posts: 13
Location: Hyderabad

PostPosted: Mon May 04, 2009 6:43 pm    Post subject: Reply to: Arithmetic and Comparisions on dates
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon May 04, 2009 11:45 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1232
Location: Israel

PostPosted: Tue May 05, 2009 2:45 am    Post subject:
Reply with quote

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
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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 37 Tue Dec 06, 2016 8:04 pm
No new posts Sort Card : To get the records with ... pecsakthivel123 DFSORT/ICETOOL 7 Thu Dec 10, 2015 11:54 pm
No new posts difference between dates in months C... josepnass Testing & Performance analysis 6 Wed Jun 18, 2014 2:30 am
No new posts problem in difference of dates Kmr.deepakcs DFSORT/ICETOOL 8 Fri Oct 25, 2013 10:19 am
No new posts How to calculate days which is differ... mahe1015 PL/I & Assembler 6 Mon Oct 21, 2013 4:39 pm


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