Corvertiion > Timestamp to YYYY-MM-DD-HH:MM:SS.ssssss for

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Corvertiion > Timestamp to YYYY-MM-DD-HH:MM:SS.ssssss for

Post by cosec »

(a) Source: DB2 UDB Database
(b) Target : Sequential file
(c) Objective: Timestamp value to be represented in YYYY-MM-DD-HH:MM:SS.ssssss format
Last edited by cosec on Wed Mar 27, 2013 9:26 pm, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is the format of the timestamp returned by DB2?
Your expression seems fine to me.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

If I don't use the substring function, the format received is as follows:

YYYY-MM-DD HH:MM:SS.ssssss (I need to have a '-' separator between the date and time).

Thanks.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What datatype is Input.EFF_DTM that you are reading from DB2? Also, is the 6th decimal digit in DB2 actually set to a value other than "1"?
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

It's TIMESTAMP in db2.

The value in the db is 2012-01-15 01:15:14.3
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

OK, so you need to convert the space to a "-" and force six places in the fractional seconds piece. Try something like this:

Code: Select all

Convert(" ", "-", Field(InLink.TheTimestamp, ".", 1,1 ) : "." : Fmt(Field(InLink.TheTimestamp, ".", 2, 1), "L%6")
That is, everything to the left of the "." with the space character converted, concatenated with a dot and then everything to the right of the dot with sufficient trailing zeroes to make six characters.

Some people prefer the alternative formulation "6'0'L" rather than "L%6" for the format string argument of the Fmt() function. They are equivalent.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply