Built in function to add months in a date

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Built in function to add months in a date

Post by Amar_nath »

hello all,

I am very new to DS

Is there any Inbuild function in DS to add number of months to a date so it will give the resulting date.


Example : date is 12/4/2001
if i want add 25 months in it
it should give resulting date as : 12/5/2003

So is there any inbuild function for that ?


Thanx in advance,
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

I don't think so. Why don't you write a routine for that?

Is this post any different from the one you made yesterday?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, now I'm confused. You've been working on this over in the TX forum and now you're suddenly over here. Which is it? Are you working with a Server job or a TX job?

If Server, we can take it from here. For TX you need to get yourself back to the original thread and continue that conversation.

I almost poked my nose into it yesterday in spite of it being over there, but didn't. I don't recall anywhere where you've defined what you consider to be a month - fixed number of calendar days (30?) or are you just incrementing the month portion of the date? Something else? What are your rules for when the day portion in the target month isn't appropriate? For example, if you add 1 month to 01/31/2006 what do you want the answer to be? 02/31/2006? 02/28/2006? 03/03/2006? Explain how in your example you get from the 4th of the month to the 5th of the month.

No-one can properly help you until you properly scope your requirements. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

He came, he posted, he posted (again), and he disappeared!!!
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Post by Amar_nath »

hey sorry guys,

by mistake i posted this topic on TX forum

And yes I am using Server job for this n dont wana write the routine for that

thax,
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Post by Amar_nath »

ohhhh and one more,

the date format in the example is DD-MM-YYYY

and for the same reason tat leap year and differnt days in months I want built in function for same
Amar_nath
Participant
Posts: 56
Joined: Tue Apr 18, 2006 5:03 am

Post by Amar_nath »

ohhhh and one more,

the date format in the example is DD-MM-YYYY

and for the same reason tat leap year and differnt days in months I want built in function for same
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Answer my questions, please. Specifically, the two questions related to your definition of a 'month' and how you want to handle invalid day problems.
-craig

"You can never have too many knives" -- Logan Nine Fingers
manojmathai
Participant
Posts: 23
Joined: Mon Jul 04, 2005 6:25 am

Post by manojmathai »

Hi

Create a job with parameter as the date to which 25 months are to be added to.

Inside the job have DB2 stage or similar database stages.
Define metadata with one field and type date.

In the sql you write
Select #Parameter# + 25 Months from sysdummy1.

Or if you are using oracle
select add_months(#parameter#,25) from dual.

Put the output to a seq file.

So the file contains the month added val.

Leave the month adding logic to DB

Cheers
Manoj
Post Reply