DSXchange: DataStage and IBM Websphere Data Integration Forum
View next topic
View previous topic
Add To Favorites
Author Message
rameshkm
Participant



Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192

Post Posted: Mon Mar 28, 2011 9:18 pm Reply with quote    Back to top    

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

Post Posted: Mon Mar 28, 2011 10:16 pm Reply with quote    Back to top    

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.
Rate this response:  
rameshkm
Participant



Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192

Post Posted: Wed Mar 30, 2011 8:58 pm Reply with quote    Back to top    

I will try it and let you know.

_________________
Ramesh Kumar.M
Rate this response:  
Not yet rated
rameshkm
Participant



Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192

Post Posted: Thu Mar 31, 2011 11:43 am Reply with quote    Back to top    

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
Rate this response:  
Not yet rated
jwiles



Group memberships:
Premium Members

Joined: 14 Nov 2004
Posts: 1236

Points: 9942

Post Posted: Thu Mar 31, 2011 11:34 pm Reply with quote    Back to top    

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.
Rate this response:  
rameshkm
Participant



Joined: 06 May 2008
Posts: 24
Location: chennai
Points: 192

Post Posted: Fri Apr 01, 2011 9:27 am Reply with quote    Back to top    

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
Rate this response:  
Not yet rated
vamsi.4a6
Participant



Joined: 22 Jan 2012
Posts: 233

Points: 1998

Post Posted: Tue May 01, 2012 6:29 am Reply with quote    Back to top    

Could anyone explain description about following format specifiers?

1)%(d,s)
2)%(H,s)
3)%(aa,w)
Rate this response:  
Not yet rated
chulett

Premium Poster


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

Post Posted: Tue May 01, 2012 6:34 am Reply with quote    Back to top    

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". Wink

_________________
-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
Rate this response:  
Not yet rated
Display posts from previous:       

Add To Favorites
View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2002 phpBB Group
Theme & Graphics by Daz :: Portal by Smartor
All times are GMT - 6 Hours