timestamp format convertion

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
praj
Participant
Posts: 14
Joined: Sat Dec 20, 2003 12:46 am

timestamp format convertion

Post by praj »

Hi all,

I am reading a datetime as a string(since, not able to read it as a timestamp in DS) from a text file e.g. "23-OCT-03 01:28:28". Now i need to convert this into a timestamp with format <yyyy-mm-dd hh:nn:ss>
e.g. "2003-10-23 01:28:28". I have tried string to timestamp conv but didnt help. Can anyone suggest a solution? .. bit new to DS. :wink:

Thanks
Praj
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

Hi Praj,

devide the string into an datepart and an timepart with stringoperations.

For example:

datepart=MyString[1,9]
timepart=MyString[8]


in the next round you use an iconv to convert it into the internal datastage date and time format

dateintern=iconv(datepart,"D-DMY[2,A3,2]")

the timepart you can take as it was.

then you convert the dateintern with oconv in an external format

dateextern=oconv(dateintern,"D-YMD[4,2,2]")

Then you put all together in one string:

NewDate=dateextern:" ":timepart

and that's it.

Good luck

Wolfgang
praj
Participant
Posts: 14
Joined: Sat Dec 20, 2003 12:46 am

Post by praj »

thanx a lot :lol:
It worked perfectly 8) :lol:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just out of curiosity, WHERE did you do this?
Your original post suggested that you were using a parallel job, which limits the places that you can use BASIC functions such as Iconv() and Oconv(), and the square bracket notation for substringing.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Post by Teej »

ray.wurlod wrote:the square bracket notation for substringing.
Actually, the square brackets are fully supported (although it seems to be undocumented) for PX Transformer, at least for 6.x.

As for converting to TimeStamp under PX: You will need to convert the Month string into a numeric value, and then let the StringToTimeStamp take care of the rest.

Time to pull out a long If Then Else statement!

-T.J.
Developer of DataStage Parallel Engine (Orchestrate).
Post Reply