Page 1 of 1

timestamp format convertion

Posted: Mon Jan 19, 2004 12:02 am
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

Posted: Mon Jan 19, 2004 2:13 am
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

Posted: Mon Jan 19, 2004 5:04 am
by praj
thanx a lot :lol:
It worked perfectly 8) :lol:

Posted: Mon Jan 19, 2004 3:10 pm
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.

Posted: Mon Jan 19, 2004 7:48 pm
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.