String to timestamp conversation

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Sagnik Mukherjee
Participant
Posts: 14
Joined: Wed Jul 25, 2012 5:29 am
Location: Mumbai

String to timestamp conversation

Post by Sagnik Mukherjee »

Hi,

In transformer stage i use String to Timestamp function like this :

StringToTimestamp(lnk_CONV.TS4,"%yyyy-%mm-%dd-%hh.%nn.%ss.%SSSSSS")

the data is coming to transformer either with this format or with 'space'.
Data in TS4 is proper.We are handling the 'space' also.
Though this transformation job is aborted showing this fatal error :


[APT_CombinedOperatorController,0: Caught exception from runLocally(): APT_ParseError: Parsing parameters "%yyyy-%mm-%dd-%hh.%nn.%ss.%SSSSSS" for conversion "timestamp=timestamp_from_string[%yyyy-%mm-%dd %hh:%nn:%ss](string)": APT_Conversion_String_TimeStamp: Invalid format [%yyyy-%mm-%dd-%hh.%nn.%ss.%SSSSSS] used for string_from_time type conversion.]

Please advice.
Sagnik
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

As the error notes, your format is invalid. From the docs:

For a timestamp, the format is %yyyy-%mm-%dd %hh:%nn:%ss. If extended to include microseconds, the format is %yyyy-%mm-%dd %hh:%nn:%ss.x, where x gives the number of decimal places seconds is given to.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sagnik Mukherjee
Participant
Posts: 14
Joined: Wed Jul 25, 2012 5:29 am
Location: Mumbai

Post by Sagnik Mukherjee »

Actually we are getting with that format only from source file and as its a multi instance job, I cant see the possibility to change the format in stagevar also.
What 2 do now.
Sagnik
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Fix your format in the transformer StringToTimestamp() function call. Nothing else to do for that particular issue.
-craig

"You can never have too many knives" -- Logan Nine Fingers
oracledba
Premium Member
Premium Member
Posts: 49
Joined: Mon Aug 06, 2012 9:21 am

Post by oracledba »

StringToTimestamp(lnk_CONV.TS4,"%yyyy-%mm-%dd-%hh.%nn.%ss.%SSSSSS")



simply only include this

StringToTimestamp(lnk_CONV.TS4)

the extra fitting is causing the error.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

oracledba wrote:simply only include this

StringToTimestamp(lnk_CONV.TS4)

the extra fitting is causing the error.
Sorry but that's just not correct and will generate syntax errors as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sagnik Mukherjee
Participant
Posts: 14
Joined: Wed Jul 25, 2012 5:29 am
Location: Mumbai

Post by Sagnik Mukherjee »

The problem has been solved. In that microsecond part instead of giving .%SSSSSS, i gave .%6. Means now I have given like this :

StringToTimestamp(lnk_CONV.TS4,"%yyyy-%mm-%dd-%hh.%nn.%ss.%6")

and the job succesfully ran.I didnot know about this format of timestamp.
Sagnik
Post Reply