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

How I can subtract days from date ?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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.

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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
Search our Forums:

Back to Top