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 to add 1 month(not 30 days) to existing date variable.

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

New User


Joined: 29 May 2006
Posts: 2
Location: India

PostPosted: Fri Dec 29, 2006 6:01 pm    Post subject: how to add 1 month(not 30 days) to existing date variable.
Reply with quote

suppose the date 1 = 30Oct06
then date 2 should be 30Nov06.

Is there any function available?
Back to top
View user's profile Send private message

William Thompson

Global Moderator


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

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

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?? icon_eek.gif

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.... icon_smile.gif
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Wed Jan 03, 2007 6:04 am    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl
Reply with quote

boopathy.gopalsamy,

Did you ever get a resolution to your question?
Back to top
View user's profile Send private message
abhijeet3162002

New User


Joined: 05 Jul 2004
Posts: 6
Location: mumbai

PostPosted: Fri Jan 05, 2007 6:28 pm    Post subject:
Reply with quote

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,
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Fri Jan 05, 2007 6:30 pm    Post subject:
Reply with quote

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??
Back to top
View user's profile Send private message
abhijeet3162002

New User


Joined: 05 Jul 2004
Posts: 6
Location: mumbai

PostPosted: Fri Jan 05, 2007 6:36 pm    Post subject:
Reply with quote

Yeah...
you r right...
I ll think on it..
Thanks
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Fri Jan 05, 2007 9:16 pm    Post subject: how to add 1 month(not 30 days) to existing date variable.
Reply with quote

try this query..

SELECT (CURRENT DATE + 1 MONTH) FROM SYSIBM.SYSDUMMY1


replace current date with your input date.
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Fri Jan 05, 2007 9:20 pm    Post subject: how to add 1 month(not 30 days) to existing date variable
Reply with quote

SELECT (DATE('2006-01-31') + 1 MONTH) FROM SYSIBM.SYSDUMMY1

will result 2006-02-28
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: Fri Jan 05, 2007 9:37 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Fri Jan 05, 2007 10:51 pm    Post subject: how to add 1 month(not 30 days) to existing date variable
Reply with quote

you can use + 1 month in a query. it is not an organization standard. its a db2 standard.
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Fri Jan 05, 2007 10:57 pm    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl
Reply with quote

If this was only a DB2 question!!!.....
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: Sat Jan 06, 2007 12:27 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Sat Jan 06, 2007 1:31 am    Post subject: Re: how to add 1 month(not 30 days) to existing date variabl
Reply with quote

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
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
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 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 Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


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