MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date to Integer

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
lakshmiraya
Beginner


Joined: 15 Jun 2007
Posts: 7
Topics: 3
Location: Pune

PostPosted: Fri Jul 20, 2007 4:47 am    Post subject: Date to Integer Reply with quote

Hi,
There two dates
Code:

CURRENT-DATE  PIC 9(8) and END-OF-MONTH-DATE  PIC 9(8) .


Both are in the format 'YYYYMMDD'.

I need to subtract CURRENT-DATE from END-OF-MONTH-DATE.

How can I do this?

DATE-TO-INTEGER function is not working!!!

Any ideas how to do this?
_________________
Thanks,
Lakshmi.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Fri Jul 20, 2007 4:52 am    Post subject: Re: Date to Integer Reply with quote

lakshmiraya wrote:
Hi,
There two dates
CURRENT-DATE PIC 9(8) and END-OF-MONTH-DATE PIC 9(8) .

Both are in the format 'YYYYMMDD'.

I need to subtract CURRENT-DATE from END-OF-MONTH-DATE.

How can I do this?

DATE-TO-INTEGER function is not working!!!

Any ideas how to do this?
What do you mean bu "not working"?
Do you have Enterprise COBOL?
What level of COBOL do you have? It is on one of the top lines of the compile listing.
Back to top
View user's profile Send private message
lakshmiraya
Beginner


Joined: 15 Jun 2007
Posts: 7
Topics: 3
Location: Pune

PostPosted: Fri Jul 20, 2007 5:09 am    Post subject: Reply with quote

I GOT IT!

THANKS.
_________________
Thanks,
Lakshmi.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Fri Jul 20, 2007 5:17 am    Post subject: Reply with quote

lakshmiraya wrote:
I GOT IT!
Got what? How about sharing?
Back to top
View user's profile Send private message
Mickeyd
Beginner


Joined: 02 Jan 2003
Posts: 27
Topics: 0

PostPosted: Fri Jul 20, 2007 12:56 pm    Post subject: Reply with quote

If both dates are in the form yyyymmdd then just substract the 2 dates.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Fri Jul 20, 2007 1:02 pm    Post subject: Reply with quote

Quote:
If both dates are in the form yyyymmdd then just substract the 2 dates.


Subtract 20060731 from 20070228 - how many days/months/years or wahtever is that?
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Jul 20, 2007 1:02 pm    Post subject: Reply with quote

Mickeyd wrote:
If both dates are in the form yyyymmdd then just substract the 2 dates.
I know that you are confused, you put this post in two threads.
I am confused; could you show me the code where you would just subtract the 2 dates Question
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
lakshmiraya
Beginner


Joined: 15 Jun 2007
Posts: 7
Topics: 3
Location: Pune

PostPosted: Sun Jul 22, 2007 11:15 pm    Post subject: Reply with quote

Here is the code:
Code:

WORKING-STORAGE SECTION.                                       
*                                                               
 01  WS-MONTH-END-DD             PIC X(24) VALUE                 
                                      '312831303130313130313031'.
 01  WS-TBL-MONTH-END REDEFINES WS-MONTH-END-DD.                 
     05 TBL-MONTH-END-DAY        PIC 9(02) OCCURS 12 TIMES.     
*                                                               
 01  WS-GREG-DATE.                                               
     05 WS-GREG-YEAR             PIC 9(4).                       
     05 WS-GREG-MNTH             PIC 9(2).                       
     05 WS-GREG-DAY              PIC 9(2).                       
*                                                 
 01  WS-CURRENT-DATE             PIC 9(21).       
 01  WS-DATE                     PIC 9(8).       
 01  WS-INT-DATE                 PIC 9(8).       
 01  WS-INT-MEDT                 PIC 9(8).       
 01  WS-INT-CRDT                 PIC 9(8).       
 01  WS-GREGARIAN-DATE           PIC 9(8).       
*                                                 

1) To get the end of month date:

     EVALUATE TRUE                                   
         WHEN FUNCTION MOD (WS-GREG-YEAR 4)   NOT ZERO
         WHEN FUNCTION MOD (WS-GREG-YEAR 100)     ZERO
          AND FUNCTION MOD (WS-GREG-YEAR 400) NOT ZERO
              MOVE '28' TO WS-TBL-MONTH-END (3: 2)   
         WHEN OTHER                                   
              MOVE '29' TO WS-TBL-MONTH-END (3: 2)   
     END-EVALUATE.                                   
*                                                     
     MOVE TBL-MONTH-END-DAY(WS-GREG-MNTH)             
                                TO WS-GREG-DAY.       
     DISPLAY 'LAST-DATE OF MONTH:' WS-GREG-DATE.     


2) To get the difference between the end of month date and the current date:

     MOVE FUNCTION CURRENT-DATE (1:8)  TO  WS-CURRENT-DATE.
*                                                               
     MOVE WS-GREG-DATE          TO WS-GREGARIAN-DATE.           
     COMPUTE WS-INT-MEDT =                                     
                    FUNCTION INTEGER-OF-DATE (WS-GREGARIAN-DATE)
                                                           
     COMPUTE WS-INT-CRDT =                                     
                    FUNCTION INTEGER-OF-DATE (WS-DATE).     
                                                               
     COMPUTE WS-INT-DATE = WS-INT-MEDT - WS-INT-CRDT.           
     DISPLAY 'INT VAL OF THE DATE DIFF: ' WS-INT-DATE.

_________________
Thanks,
Lakshmi.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
lakshmiraya
Beginner


Joined: 15 Jun 2007
Posts: 7
Topics: 3
Location: Pune

PostPosted: Sun Jul 22, 2007 11:21 pm    Post subject: Reply with quote

Here is the code:
Code:

WORKING-STORAGE SECTION.
*
01 WS-MONTH-END-DD PIC X(24) VALUE
'312831303130313130313031'.
01 WS-TBL-MONTH-END REDEFINES WS-MONTH-END-DD.
05 TBL-MONTH-END-DAY PIC 9(02) OCCURS 12 TIMES.
*
01 WS-GREG-DATE.
05 WS-GREG-YEAR PIC 9(4).
05 WS-GREG-MNTH PIC 9(2).
05 WS-GREG-DAY PIC 9(2).
*
01 WS-CURRENT-DATE PIC 9(21).
01 WS-INT-DATE PIC 9(8).
01 WS-INT-MEDT PIC 9(8).
01 WS-INT-CRDT PIC 9(8).
01 WS-GREGARIAN-DATE PIC 9(8).
*

1) To get the end of month date:

EVALUATE TRUE
WHEN FUNCTION MOD (WS-GREG-YEAR 4) NOT ZERO
WHEN FUNCTION MOD (WS-GREG-YEAR 100) ZERO
AND FUNCTION MOD (WS-GREG-YEAR 400) NOT ZERO
MOVE '28' TO WS-TBL-MONTH-END (3: 2)
WHEN OTHER
MOVE '29' TO WS-TBL-MONTH-END (3: 2)
END-EVALUATE.
*
MOVE TBL-MONTH-END-DAY(WS-GREG-MNTH)
TO WS-GREG-DAY.
DISPLAY 'LAST-DATE OF MONTH:' WS-GREG-DATE.


2) To get the difference between the end of month date and the current date:

MOVE FUNCTION CURRENT-DATE (1:8) TO WS-CURRENT-DATE.
*
MOVE WS-GREG-DATE TO WS-GREGARIAN-DATE.
COMPUTE WS-INT-MEDT =
FUNCTION INTEGER-OF-DATE (WS-GREGARIAN-DATE)

COMPUTE WS-INT-CRDT =
FUNCTION INTEGER-OF-DATE (WS-CURRENT-DATE).

COMPUTE WS-INT-DATE = WS-INT-MEDT - WS-INT-CRDT.
DISPLAY 'INT VAL OF THE DATE DIFF: ' WS-INT-DATE.

_________________
Thanks,
Lakshmi.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group