| Author |
Message |
rameshkm
Participant
Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192
|
|
| DataStage® Release: 8x |
| Job Type: Parallel |
| OS: Unix |
| Additional info: time parts with AM/PM |
Hi,
I have a string value as "Jan 22 2010 2:12:44:201PM", i want to convert this string value to timestamp like 2010-01-22 14:12:44:201, is there any short way to handle this ? mean minimum using of stage variable.
Thanks
|
_________________ Ramesh Kumar.M |
|
|
|
 |
jwiles

Group memberships: Premium Members
Joined: 14 Nov 2004
Posts: 1236
Points: 9942
|
|
|
|
|
|
Is the :201 portion of the time supposed to be milliseconds? Assuming so:
Convert to a timestamp by using StringToTimestamp() with a format specifier of "%mmm %d %yyyy %H:%n:%s:%SSS%aa"
When you're ready to output to a text field, or a flat file, use TimestampToString() with a format specifier of "%yyyy-%mm-%dd %hh:%nn:%ss:%SSS"
You may have to play around with the format specifiers a little bit...they are documented in the Parallel Job Developer Guide.
Regards,
|
_________________ - james wiles
All generalizations are false, including this one - Mark Twain.
|
|
|
|
 |
rameshkm
Participant
Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192
|
|
|
|
|
|
|
I will try it and let you know.
|
_________________ Ramesh Kumar.M |
|
|
|
 |
rameshkm
Participant
Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192
|
|
|
|
|
|
Hi
Please find the error below, while i tried to use your approach
--------------------------------------------------------------------------------
XFR_In_Trans_1,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "%mmm %d %yyyy %H:%n%s:%(SSS,v)%aa" for conversion "timestamp=timestamp_from_string[%yyyy-%mm-%dd %hh:%nn:%ss](string)": APT_Conversion_String_TimeStamp: Invalid format [%mmm %d %yyyy %H:%n%s:%(SSS,v)%aa] used for string_from_time type conversion.
--------------------------------------------------------------------------------
Please help in this, whether I have change any default Timestamp String format ?
|
_________________ Ramesh Kumar.M |
|
|
|
 |
jwiles

Group memberships: Premium Members
Joined: 14 Nov 2004
Posts: 1236
Points: 9942
|
|
|
|
|
|
You're missing the colon between %n and %s in the time portion of the format string. For some reason, the format validator doesn't like it.
Regards,
|
_________________ - james wiles
All generalizations are false, including this one - Mark Twain.
|
|
|
|
 |
rameshkm
Participant
Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192
|
|
|
|
|
|
Hi Friend,
Its working fine , i used the below format to achive this
StringToTimestamp(Column1,"%mmm %(d,s) %yyyy %(H,s):%n:%s:%SSS%(aa,w)")
, thank you so much, i never forget this great help
|
_________________ Ramesh Kumar.M |
|
|
|
 |
vamsi.4a6
Participant
Joined: 22 Jan 2012
Posts: 233
Points: 1998
|
|
|
|
|
|
Could anyone explain description about following format specifiers?
1)%(d,s)
2)%(H,s)
3)%(aa,w)
|
|
|
|
|
 |
chulett
 since January 2006
Group memberships: Premium Members, Inner Circle, Server to Parallel Transition Group
Joined: 12 Nov 2002
Posts: 36583
Location: Denver, CO
Points: 186480
|
|
|
|
|
|
| vamsi.4a6 wrote: |
| Could anyone explain description about following format specifiers? |
| jwiles wrote: |
| You may have to play around with the format specifiers a little bit...they are documented in the Parallel Job Developer Guide. |
Oddly enough, in a section titled "Date and time formats".
|
_________________ -craig
It's a scheme of devices to get at low prices all goods from cough mixtures to cables
Which tickled the sailors by treating retailers as though they were all veg-e-tables
|
|
|
|
 |
|
|