timestamp_from_string with microseconds in Modify Stage
Posted: Wed Mar 15, 2017 7:27 am
Hi,
I have a job that reads from an Oracle table and writes to a Dataset doing transformation on one field.
One of the fields (DATETIME_FIELD) has microseconds and it is stored in Oracle as a varchar
Example: 20161231 11:35:12.123456
I am trying to convert it to a TIMESTAMP with a Modify Stage using:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.%6] (DATETIME_FIELD)
but I get an error:
main_program: Error parsing modify adapter: Error in binding: Parsing parameters "%yyyy%mm%dd %hh:%nn:%ss.%6" 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.%6] used for string_from_time type conversion
Expected destination field selector, got: ")"; input:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.%6] (DATETIME_FIELD)
I also tried removing the % before the 6:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.6] (DATETIME_FIELD)
I do not get any errors but the data comes out as: 20161231 11:35:12.000000
Strangely enough if I use a Transformer Stage instead using the same formatting:
StringToTimestamp(DATETIME_FIELD,"%yyyy%mm%dd %hh:%nn:%ss.6")
The data is correct: 20161231 11:35:12.123456
In both cases the destination field on the Output tab is defined as Timestamp with Extended = Microseconds.
I can go with the transformer stage if need be but I would like to know why the modify is not working. Any ideas??
Thanks in advance.
I have a job that reads from an Oracle table and writes to a Dataset doing transformation on one field.
One of the fields (DATETIME_FIELD) has microseconds and it is stored in Oracle as a varchar
Example: 20161231 11:35:12.123456
I am trying to convert it to a TIMESTAMP with a Modify Stage using:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.%6] (DATETIME_FIELD)
but I get an error:
main_program: Error parsing modify adapter: Error in binding: Parsing parameters "%yyyy%mm%dd %hh:%nn:%ss.%6" 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.%6] used for string_from_time type conversion
Expected destination field selector, got: ")"; input:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.%6] (DATETIME_FIELD)
I also tried removing the % before the 6:
DATETIME_FIELD = timestamp_from_string[%yyyy%mm%dd %hh:%nn:%ss.6] (DATETIME_FIELD)
I do not get any errors but the data comes out as: 20161231 11:35:12.000000
Strangely enough if I use a Transformer Stage instead using the same formatting:
StringToTimestamp(DATETIME_FIELD,"%yyyy%mm%dd %hh:%nn:%ss.6")
The data is correct: 20161231 11:35:12.123456
In both cases the destination field on the Output tab is defined as Timestamp with Extended = Microseconds.
I can go with the transformer stage if need be but I would like to know why the modify is not working. Any ideas??
Thanks in advance.