Page 1 of 1

Built in function to add months in a date

Posted: Thu May 18, 2006 12:43 am
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,

Posted: Thu May 18, 2006 2:02 am
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?

Posted: Thu May 18, 2006 7:04 am
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. :?

Posted: Thu May 18, 2006 11:57 am
by gateleys
He came, he posted, he posted (again), and he disappeared!!!

Posted: Thu May 18, 2006 11:26 pm
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,

Posted: Thu May 18, 2006 11:30 pm
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

Posted: Thu May 18, 2006 11:31 pm
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

Posted: Thu May 18, 2006 11:40 pm
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.

Posted: Fri May 19, 2006 5:05 am
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