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
 

 

Date manipulation

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

New User


Joined: 20 Dec 2006
Posts: 55
Location: noida

PostPosted: Thu Sep 10, 2009 3:35 pm    Post subject: Date manipulation
Reply with quote

I have a query regarding the manipulation of date.
I have a future date (in CCYYMMDD format) and I have to find out 1 month before date.
For example -
Future date = 12 Oct 2009, 1 month before = 12 Sep 2009
Future date = 31 Oct 2009, 1 month before = 31 Sep 2009 which is wrong. In this case I want the date as 1 Oct 2009.

Is there any COBOL function which can handle this?
The processing I am looking for is not in terms of no. of days. I want a valid date after subtracting 1 from the month field of the future date.

Please help.
Back to top
View user's profile Send private message

Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Thu Sep 10, 2009 3:59 pm    Post subject:
Reply with quote

Hi,
There are many shops which have internal utilities which do such operation,
I have heard that in COBOL II that have some function which perform date operation but if this is not possible then you have to use the DB2 for doing the above mentioned requirement
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Thu Sep 10, 2009 4:26 pm    Post subject:
Reply with quote

Shanu,
Please check this previous topic.

http://www.ibmmainframes.com/viewtopic.php?t=30525
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Thu Sep 10, 2009 4:35 pm    Post subject: Reply to: Date manipulation
Reply with quote

Quote:
Future date = 31 Oct 2009, 1 month before = 31 Sep 2009 which is wrong.
In this case I want the date as 1 Oct 2009.

two issues to point out...
- if the program is not dealing with DB2 it is silly to introduce a DB2 dependency simply for date calculations

- Your requirement is not satisfied by the common available practices for date calculations ( db2 at least )
Quote:
Incrementing and decrementing dates: The result of adding a duration to a date, or of subtracting a duration from a date, is itself a date. (For the purposes of this operation, a month denotes the equivalent of a calendar page. Adding months to a date, then, is like turning the pages of a calendar, starting with the page on which the date appears.) The result must fall between the dates January 1, 0001 and December 31, 9999 inclusive. If a duration of years is added or subtracted, only the year portion of the date is affected. The month is unchanged, as is the day unless the result would be February 29 of a non-leap-year. Here the day portion of the result is set to 28, and the SQLWARN6 field of the SQLCA is set to W, indicating that an end-of-month adjustment was made to correct an invalid date. DB2 Application Programming and SQL Guide also describes how SQLWARN6 is set.

Similarly, if a duration of months is added or subtracted, only months and, if necessary, years are affected. The day portion of the date is unchanged unless the result would be invalid (September 31, for example). In this case the day is set to the last day of the month, and the SQLWARN6 field of the SQLCA is set to W to indicate the adjustment.


so You will have to write Your own code anyway

but i find odd that many, too many, organizations have not yet
defined and implemented a common set of rules and subroutines for date calculations
the whole issue is quite murky, legal and standards concerns included
( for example which is the first and last week of the year,
how many weeks in a year, sometimes 52, sometimes 53 )

not an issue to be dealt by each application programmer (*)

(*) hope that it is the politically correct job description..
car salesmen prefer to be called "mobility consultants" icon_biggrin.gif
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Thu Sep 10, 2009 5:02 pm    Post subject:
Reply with quote

http://www.ibmmainframes.com/viewtopic.php?t=39153&highlight=
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: Thu Sep 10, 2009 8:46 pm    Post subject:
Reply with quote

Hello,

Quote:
Future date = 31 Oct 2009, 1 month before = 31 Sep 2009 which is wrong. In this case I want the date as 1 Oct 2009.
Why would 1 OCT be "1 month before" 31 OCT? I've seen many implementations of date "arithmetic" and "1 month before" never yielded a date in the same month. . .

As Enrico mentioned, the "rules" must be well understood before someone starts slinging code. And these rules should not be created by individual programmers/analysts/dba's, etc.
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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


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