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
 

 

How I can subtract days from date ?

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

New User


Joined: 15 Sep 2005
Posts: 11

PostPosted: Thu Jun 08, 2006 7:54 pm    Post subject: How I can subtract days from date ?
Reply with quote

HI all,


Need ur help. I want to subtract 10 days from the date which is in the YYYYMMDD format.

For example if 20060403 is the data than after subtracting 10 it should be
20060323. OR if date is 20060102 than after subtracting it should be 20051222.

Is there is any function for it.
It would be great if u give me some link to perform these type of arithmetic operation on date.

Thanx
Back to top
View user's profile Send private message

amitrath

New User


Joined: 30 Apr 2004
Posts: 28
Location: Carmel, USA.

PostPosted: Fri Jun 09, 2006 4:45 am    Post subject: Re: How I can subtract days from date ?
Reply with quote

I have done this by using a 3 step procedure:

    Convert the YYMMDD date to Days-of-century (nbr of days starting from century) format
    Substract 10 from days-of-century format
    Convert the resul back to YYMMDD format
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Jun 12, 2006 7:58 pm    Post subject: Re: How I can subtract days from date ?
Reply with quote

Direction,

Check these two functions: (You must be using ?Enterprise COBOL? through)

INTEGER-OF-DATE

DATE-OF-INTEGER

Dave
Back to top
View user's profile Send private message
amitrath

New User


Joined: 30 Apr 2004
Posts: 28
Location: Carmel, USA.

PostPosted: Tue Jun 13, 2006 5:42 am    Post subject: Re: How I can subtract days from date ?
Reply with quote

Also here are some great algorithms for date conversion. May look complex, but once you understand it, it's finally a few lines of code change.

http://www.vsg.cape.com/~pbaum/date/date0.htm
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jun 25, 2006 12:59 am    Post subject:
Reply with quote

This should work:
Code:

05  INT-DAYS               PIC S9(008) COMP.
05  NEW-CYMD               PIC  9(008).


COMPUTE INT-DAYS = (INTEGER-OF-DATE(YOUR-CYMD) - 10)
COMPUTE NEW-CYMD = (DATE-OF-INTEGER(INT-DAYS)

DISPLAY 'OLD DATE '  YOUR-CYMD
DISPLAY 'NEW DATE '  NEW-CYMD
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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


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