how to add two input time columns

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
arasan
Participant
Posts: 44
Joined: Wed Nov 30, 2005 3:54 am
Contact:

how to add two input time columns

Post by arasan »

how to add 2 input time columns

for example:

input A ----- 200408160545
YYMMDDHHSS (YEAR/MONTH/HOUR/SEC)
+
input B ------ 0030(HOUR/SS)

OUTPUT SHOULD BE IN THS FORMAT: 200408160615
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The DataStage PX developer's guide lists the date/time functions on pages B-1 and B-2; if you convert you string to a timestamp you can use those functions. Another way would be to do your own date math; convert the characters yourself into numbers representing yyyy, mm, dd and hh:mm:ss and do the math, then use the builtin functions to convert that to your requested output format.

In this case it might be best to convert the string date into a julian date which makes maths easier, then convert that julian date to a display date.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You're almost certainly going to need something custom here, because there's nothing out of the box to add date/time data.

Be aware that you need to handle situations like the result not being on the same day as the original date/time, and possibly a negative time to add.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sunshine2323
Charter Member
Charter Member
Posts: 130
Joined: Mon Sep 06, 2004 3:05 am
Location: Dubai,UAE

Post by Sunshine2323 »

Hi arasan,

TimestampFromSecondsSince(seconds,timestamp) Function

Use the StringToTimestamp(string,"%yyyy%mm%dd%hh%nn") function to convert the string to Timestamp

Convert the input B ------(HOUR/SS) into seconds
e.g. 1330 = (13*60*60+30) seconds
and then use the above function (TimestampFromSecondsSince) to add the seconds to the timestamp and you will get the desired result.

Hope this helps :)
Warm Regards,
Amruta Bandekar

<b>If A equals success, then the formula is: A = X + Y + Z, X is work. Y is play. Z is keep your mouth shut. </b>
--Albert Einstein
Post Reply