Extract Date and Time from TimeStamp Column

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
lna_dsuser
Premium Member
Premium Member
Posts: 29
Joined: Tue Aug 14, 2012 1:06 pm

Extract Date and Time from TimeStamp Column

Post by lna_dsuser »

Hi,

I have a requirement where I need to Extract the "Date" and "Time" Value from timestamps column..

Column "C" is Defined DataType as TimeStamp and has value as "2013-09-21 21:22:22" I need to get Date in Column "A" (DataType = Date) and Time in Column "B" (DataType = Time).
This is what I did :

A = field(C," ",1) = 2012-09-21
B = field(C," ",2) = 21:22:22

I am able to populate Column "A" and "B" with respective Date and Time Value as mentioned above. "

The value coming in "A" is a sting and is successfully getting populated to Date Column "A". I can convert the Sting to Date by using "StingtoDate" function as well and same I can do for Time Column "B"

My question is that is this the best approach and will give optimal performance and will not cause any issue or I can use other method or function to do this.... I am doing this is DS8.1...

I would appreciate, if somebody can advise on this....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can't check right now but I seem to recall a 'date from timestamp' function as well as a 'time from timestamp' one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
lna_dsuser
Premium Member
Premium Member
Posts: 29
Joined: Tue Aug 14, 2012 1:06 pm

Post by lna_dsuser »

Thanks Craig for your reply..The function is "TimeStamptoDate" and "TimeStamptoTime" function....Is that the best option then using "Field"...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes. Only use a 'generic' function when there isn't a specific / dedicated one for the task.
-craig

"You can never have too many knives" -- Logan Nine Fingers
lna_dsuser
Premium Member
Premium Member
Posts: 29
Joined: Tue Aug 14, 2012 1:06 pm

Post by lna_dsuser »

Thanks !!!! Appreciate your help.....
Post Reply