Add minutes to a date/timestamp

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
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Add minutes to a date/timestamp

Post by Anthony1200 »

Hi guys,

I was wondering if there is a smart way to add minutes to a date to form a timestamp. I want to create a routine that has 2 parameters, one for the Date/timestamp (when a date is entered with no time 00:00:00 is set as default time) and one for the minutes to be added. I cant simply concatenate both values since the day can change if the time gets past 24:00 etc..
Is this possible with iconv? i cant seem to get this to work.

Kind regards,
A
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You have to handle both the date and time separately and yes, manage the date change based on what the time was incremented to. Which means you need a routine and can't do it straight in a transformer derivation.

I know Ray has some date handling routines freely available on his site and Ken Bland has some in his job control utilities, links to both of which have been posted here in the past. And I'll see what I can find later when I get into the office and can spare some time.
-craig

"You can never have too many knives" -- Logan Nine Fingers
dinakaran_s
Participant
Posts: 22
Joined: Wed Jul 02, 2008 7:01 am
Location: London

Post by dinakaran_s »

Hi,

Create 2 stage variable for contactinating date and time rather than writing routine. In this below rule the time can have more than 2 digit as Hour (ex: 150:00:60).

Lets us assume the input variable as below
vDate = Date format
vTime = time format

**svDays stage variable calculates the no of days in the given time format
svDays = (field(vTime,":",1) - Mod(field(vTime,":",1),24))/24

** This Stage variable will convert the existing date to internal format(Number). Now add the no of days to the internal value and convert back to normal date format. Then concat the Time with the date.

svConcatDateTime = Oconv( (IConv(vDate,"D/YMD[4,2,2]") + svDays ) ,"D/YMD[4,2,2,]") : " " : Mod(field(vTime,":",1),24) : ":" : Field(vTime,":",2)
Anthony1200
Premium Member
Premium Member
Posts: 28
Joined: Wed Mar 28, 2007 6:57 am
Location: Amsterdam

Post by Anthony1200 »

Hi,

Super, this is what I needed :)

Thanks!!!!
Post Reply