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

Number of days between two dates in Easytrieve


IBM Mainframe Forums -> CA Products
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Mon Nov 26, 2007 8:37 pm
Reply with quote

Hi,

Is there any macro to calculate number of days between two dates in Easytrieve?

Thank you
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Nov 27, 2007 6:24 am
Reply with quote

Dil,

Few date Macros are available with 'Easytreive addons' (which ofcourse are paid ones icon_sad.gif ).

If you are lucky enough icon_smile.gif , those may be installed at your shop icon_cool.gif icon_cool.gif .
Back to top
View user's profile Send private message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Thu Nov 29, 2007 8:31 pm
Reply with quote

Is there any other method or programming logic for this?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Thu Nov 29, 2007 8:42 pm
Reply with quote

Delip wrote:
Is there any other method or programming logic for this?
Other?
You can use the programming function of EZT to calculate the difference between two dates. A small table of the number of days in each month would be a good starting point. The complexity increases if you have large multi-year spans and you really want a high degree of accuracy as you need to account for leap years.
Back to top
View user's profile Send private message
lcmontanez

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Thu Nov 29, 2007 9:28 pm
Reply with quote

If the date is Julian the calc may be a bit more simple.

you can use DATECONV to change format.
Back to top
View user's profile Send private message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Thu Nov 29, 2007 9:34 pm
Reply with quote

Is there any other method or programming logic for this?
Back to top
View user's profile Send private message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Sat Dec 01, 2007 1:38 am
Reply with quote

I developed programming logic though a bit lengthy,it is working now.Thank you.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Sat Dec 01, 2007 1:58 am
Reply with quote

Delip wrote:
I developed programming logic though a bit lengthy,it is working now.Thank you.
It usually can be quite involved and lengthy, but I'm glad you got it working......
Back to top
View user's profile Send private message
lcmontanez

New User


Joined: 19 Jun 2007
Posts: 50
Location: Chicago

PostPosted: Sat Dec 01, 2007 3:35 am
Reply with quote

Delip wrote:
I developed programming logic though a bit lengthy,it is working now.Thank you.


If you don't mind... please post your solution just in case some else has the same problem/question
Back to top
View user's profile Send private message
Delip

New User


Joined: 13 Sep 2007
Posts: 46
Location: Bangalore

PostPosted: Mon Dec 03, 2007 7:58 pm
Reply with quote

Please find attahment.You may find it too lengthy.But I couldn't help it.
Code:

MACRO  DATE1 DATE2 DIFF
DEFINE    WS-DATE1     W        8 N
DEFINE     WSYY1    WS-DATE1    4 N
DEFINE     WSMM1    WS-DATE1 +4 2 N
DEFINE     WSDD1    WS-DATE1 +6 2 N
DEFINE    WS-DATE2     W        8 N
DEFINE     WSYY2    WS-DATE2    4 N
DEFINE     WSMM2    WS-DATE2 +4 2 N
DEFINE     WSDD2    WS-DATE2 +6 2 N
DEFINE    WS-DAYS1  W 6 N VALUE 0.
DEFINE    WS-DAYS2  W 6 N VALUE 0.
DEFINE    WS-DAYS3  W 6 N VALUE 0.
DEFINE    WS-YEAR-DIFF W 6 N VALUE 0
DEFINE    WS-LEAP      W 6 N VALUE 0
    WS-DATE1 = &DATE1
    WS-DATE2 = &DATE2
    WS-DAYS1 = 0
    WS-DAYS2 = 0
    WS-DAYS3 = 0
    WS-YEAR-DIFF = 0
    WS-LEAP = 0
    IF WSYY2 NE WSYY1
       WS-LEAP = WSYY1 / 4
       WS-LEAP = WS-LEAP * 4
       IF ((WSMM1 = 3) OR (WSMM1 = 5) OR (WSMM1 = 7) OR (WSMM1 = 8) )
          WS-DAYS1 = 31 - WSDD1
       END-IF
       IF ((WSMM1 = 10) OR (WSMM1 = 12) OR (WSMM1 = 01))
          WS-DAYS1 = 31 - WSDD1
       END-IF
       IF ((WSMM1 = 4) OR (WSMM1 = 6) OR (WSMM1 = 9) OR (WSMM1 = 11))
           WS-DAYS1 = 30 - WSDD1
       END-IF
       IF WSMM1 = 2
          IF WS-LEAP = WSYY1
             WS-DAYS1 = 29 - WSDD1
          ELSE
             WS-DAYS1  = 28 - WSDD1
          END-IF
       END-IF
       DO WHILE WSMM1 < 12
          WSMM1 = WSMM1 + 1
          IF ((WSMM1 = 3) OR (WSMM1 = 5) OR (WSMM1 = 7) OR (WSMM1 = 8))
             WS-DAYS1 = WS-DAYS1 + 31
          END-IF
          IF ((WSMM1 = 10) OR (WSMM1 = 12))
             WS-DAYS1 = WS-DAYS1 + 31
          END-IF
          IF ((WSMM1 = 4) OR (WSMM1 = 6) OR (WSMM1 = 9) OR (WSMM1 = 11))
             WS-DAYS1 = WS-DAYS1 + 30
          END-IF
          IF WSMM1 = 2
             IF WS-LEAP  = WSYY1
                WS-DAYS1 = 29 + WS-DAYS1
             ELSE
                WS-DAYS1  = 28 + WS-DAYS1
             END-IF
          END-IF
    END-DO
    END-IF
    DO WHILE WSMM2 > 0
       WSMM2 = WSMM2 - 1
       IF ((WSMM2 = 3) OR (WSMM2 = 5) OR (WSMM2 = 7) OR (WSMM2 = 8) )
          WS-DAYS2 = WS-DAYS2 + 31
       END-IF
       IF ((WSMM2 = 10) OR (WSMM2 = 1))
          WS-DAYS2 = WS-DAYS2 + 31
       END-IF
       IF ((WSMM2 = 4) OR (WSMM2 = 6) OR (WSMM2 = 9) OR (WSMM2 = 11))
          WS-DAYS2 = WS-DAYS2 + 30
       END-IF
       IF WSMM2 = 2
          WS-LEAP = WSYY2 / 4
          WS-LEAP = WS-LEAP * 4
          IF WS-LEAP  = WSYY2
             WS-DAYS2 = 29 + WS-DAYS2
          ELSE
             WS-DAYS2 = 28 + WS-DAYS2
       END-IF
       END-IF
    END-DO
    WS-DAYS2 = WS-DAYS2 + WSDD2
    IF WSYY2 = WSYY1
       DO WHILE WSMM1 > 0
          WSMM1 = WSMM1 - 1
          IF ((WSMM1 = 3) OR (WSMM1 = 5) OR (WSMM1 = 7) OR (WSMM1 = 8) )
             WS-DAYS1 = WS-DAYS1 + 31
          END-IF
          IF ((WSMM1 = 10) OR (WSMM1 = 1))
             WS-DAYS1 = WS-DAYS1 + 31
          END-IF
          IF ((WSMM1 = 4) OR (WSMM1 = 6) OR (WSMM1 = 9) OR (WSMM1 = 11))
             WS-DAYS1 = WS-DAYS1 + 30
          END-IF
          IF WSMM1 = 2
             WS-LEAP = WSYY1 / 4
             WS-LEAP = WS-LEAP * 4
             IF WS-LEAP  = WSYY1
                WS-DAYS1 = 29 + WS-DAYS1
             ELSE
                WS-DAYS1 = 28 + WS-DAYS1
             END-IF
            END-IF
      END-DO
       WS-DAYS1 = WS-DAYS1 + WSDD1
       WS-DAYS3 = WS-DAYS2 - WS-DAYS1
    ELSE
       WS-YEAR-DIFF = WSYY2 - 1 - WSYY1
       WS-LEAP      = WS-YEAR-DIFF / 4
       WS-DAYS3 = WS-DAYS1 + WS-DAYS2 + (WS-YEAR-DIFF * 365) + WS-LEAP
    END-IF
   
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 -> CA Products

 


Similar Topics
Topic Forum Replies
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top