TimestampTodate

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
Ush
Participant
Posts: 55
Joined: Tue Dec 04, 2007 3:15 am

TimestampTodate

Post by Ush »

Hi
I have datetime column which can be either in this format :
'21-01-2008 12:00:00' or '21-01-2008'.

I have to convert timestamp to date:
TimestampToDate function accepts only timestamp as input.

Please let me know as how to convert the same.

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Make sure that your datetime column is never in the second format.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

Read the data as varchar and check the length. If it is 10 then you can directly map it to your output field. If it is greater than 10 then use field() with space as the delimiter and get the first half.
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

If you are pulling the field from the database, just use Trunc(Field) which gives you only the date.
Pull that through the transformer without doing anything.

Or as Maveric said,
Read the data as varchar and check if the length is more than 10. If it is more than 10,

Code: Select all

Left(Field,10)
If you want to convert it back to date- use StringToDate() :)
Thanks and Regards!!
dspxlearn
Post Reply