Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
boopathy.gopalsamy

New User

Joined: 29 May 2006
Posts: 2
Location: India

 Posted: Fri Dec 29, 2006 6:01 pm    Post subject: how to add 1 month(not 30 days) to existing date variable. suppose the date 1 = 30Oct06 then date 2 should be 30Nov06. Is there any function available?

William Thompson

Global Moderator

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

Posted: Fri Dec 29, 2006 6:19 pm    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl

 boopathy.gopalsamy wrote: suppose the date 1 = 30Oct06 then date 2 should be 30Nov06.
But suppose the date 1 = 30Jan06
then date 2 should be 30Feb06??

You might want to explore this thread http://www.ibmmainframes.com/viewtopic.php?t=16678&highlight=13+months
 Quote: Is there any function available?
Not really, the tricky part is what are you going to do for the exceptions as noted above....
DavidatK

Active Member

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

 Posted: Wed Jan 03, 2007 6:04 am    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl boopathy.gopalsamy, Did you ever get a resolution to your question?
abhijeet3162002

New User

Joined: 05 Jul 2004
Posts: 6
Location: mumbai

 Posted: Fri Jan 05, 2007 6:28 pm    Post subject: You can convert your date in dd-mmmm format where dd will be day of the month ( between 1 to 31) and mmmm will be months since 1900. ( both variables will be numeric). you can advance month by just adding 1 to mmmm variable. you can convert this date in mm-dd-yyyy format by just divind mmmm by 12. reminder will be month ( for reminder 0 month will be december) and 1800 + quotient will give you exact year. Hope I am clear. Cheers,
William Thompson

Global Moderator

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

Posted: Fri Jan 05, 2007 6:30 pm    Post subject:

 abhijeet3162002 wrote: You can convert your date in dd-mmmm format where dd will be day of the month ( between 1 to 31) and mmmm will be months since 1900. ( both variables will be numeric). you can advance month by just adding 1 to mmmm variable. you can convert this date in mm-dd-yyyy format by just divind mmmm by 12. reminder will be month ( for reminder 0 month will be december) and 1800 + quotient will give you exact year.
But suppose the date 1 = 30Jan06
then date 2 should be 30Feb06??
abhijeet3162002

New User

Joined: 05 Jul 2004
Posts: 6
Location: mumbai

 Posted: Fri Jan 05, 2007 6:36 pm    Post subject: Yeah... you r right... I ll think on it.. Thanks
raghunathns

Active User

Joined: 08 Dec 2005
Posts: 127
Location: rochester

 Posted: Fri Jan 05, 2007 9:16 pm    Post subject: how to add 1 month(not 30 days) to existing date variable. try this query.. SELECT (CURRENT DATE + 1 MONTH) FROM SYSIBM.SYSDUMMY1 replace current date with your input date.
raghunathns

Active User

Joined: 08 Dec 2005
Posts: 127
Location: rochester

 Posted: Fri Jan 05, 2007 9:20 pm    Post subject: how to add 1 month(not 30 days) to existing date variable SELECT (DATE('2006-01-31') + 1 MONTH) FROM SYSIBM.SYSDUMMY1 will result 2006-02-28
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Fri Jan 05, 2007 9:37 pm    Post subject: Hello, Before you write any code or use any built-in date functions, you will want to get a definition of what "+1 month" is in your organization. Once the rule has been defined, you can then implement your code. As W.T. mentioned, there is another similar thread in this forum.
raghunathns

Active User

Joined: 08 Dec 2005
Posts: 127
Location: rochester

 Posted: Fri Jan 05, 2007 10:51 pm    Post subject: how to add 1 month(not 30 days) to existing date variable you can use + 1 month in a query. it is not an organization standard. its a db2 standard.
DavidatK

Active Member

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

 Posted: Fri Jan 05, 2007 10:57 pm    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl If this was only a DB2 question!!!.....
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Sat Jan 06, 2007 12:27 am    Post subject:

Hello,

Yes, you can use + 1 month in a query. That does NOT mean the result will be acceptable in all organizations. As widely used as DB2 is, it does not yet dictate business rules.

If they have db2
 Quote: If this was only a DB2 question!!!.....
and if the result is correct for that organization, great - if not other means should be used for this calculation.
DavidatK

Active Member

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

 Posted: Sat Jan 06, 2007 1:31 am    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl Dick is right, Every organization can be different, especially when it comes to fiscal weeks, months, and years. As an example, an organizations fiscal month could start on the first Sunday on the calendar month, putting the start of the fiscal year, first month and week on January 7, 2007. Probably, the DB2 algorithm will be correct though, but as Dick said, you need to check. And you now need to be a DB2 program
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us