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.
Thanks
Praj
timestamp format convertion
Moderators: chulett, rschirm, roy
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
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Actually, the square brackets are fully supported (although it seems to be undocumented) for PX Transformer, at least for 6.x.ray.wurlod wrote:the square bracket notation for substringing.
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).