Timestamp Conversion

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
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Timestamp Conversion

Post by kumar66 »

Hi All,

I need to convert a Timestamp value
"2009-12-13 08:46:45" to the format "13/12/2009 08:46:45."

The input datatype is timestamp and the output datatype is also timestamp.

I tried converting the input to string and converting the string to timestamp by using the function:
timestamp to string(input)
string to timestamp(input,"%dd/%mm/%yyyy %hh:%mm:%ss)

But it is not working for me.

Please Advise.

Thanks & Regards,
Kumar66
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

where are you writing that value, a sequential file or a database?

Time you define it as time stamp the value will be in default format
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi priyadarshikunal,


Thanks for your reply. I am loading to DB2 table .

Thanks & Regards,
Kumar66
sohasaid
Premium Member
Premium Member
Posts: 115
Joined: Tue May 20, 2008 3:02 am
Location: Cairo, Egypt

Re: Timestamp Conversion

Post by sohasaid »

Try to use this function:

StringToTimeStamp(Convert ("-", "/", TimeStampToString<COLUMN_NAME>))
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Kumar66,

A timestamp (and date, time as well as all numeric datatypes) has no format; thus what you are doing when going from one timestamp to another timestamp is using up CPU but not changing any value at all. All of the 'binary' datatypes are without a format until they are assigned to a string or other output format. At that point in time a format is applied to them and they are converted from their internal representation according to that picture.
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Re: Timestamp Conversion

Post by kumar66 »

[quote="sohasaid"]Try to use this function:

Hi Sohasaid,

Thanks for your input. i tried the follwoing:

StringToTimeStamp(Convert ("-", "/", TimeStampToString(DSLink2.BEGIN_DATE_TIME,"%dd/%mm/%yyyy %hh:%nn:%ss")),"%dd/%mm/%yyyy %hh:%nn:%ss")

But it throws the error:
APT_CombinedOperatorController,1: Data string '13/12/2009 08:47:32' does not match format '%yyyy/%mm/%dd %hh:%nn:%ss': the value for tag %yyyy has fewer characters than expected.

Please Advice.

Thanks,
Kumar66
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

you haven't read the post from Arnd.

Incase you are loading it to DB2 table, you don't have to do any conversion as any database will not preserve the format.

If you are reading it from any client - you should be able to configure that from there, or change NLS timestamp format/default timestamp format of your database to see it in desired format.

You are just overkilling the system and forcing it to do extra processing, which is not needed.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
kumar66
Participant
Posts: 265
Joined: Thu Jul 26, 2007 12:14 am

Post by kumar66 »

Hi All,

Thanks for your suggestions.

I loaded the the tiesatmp value directly to the DB2 table without changing the format .

But Db2 is storing the date formt as 13-Jan-2010 10:12:34 AM .
I need the format to be stored as 13-01-2010 10:12:34.

How can I chage the date format in DB2?

Please Advice.

Thanks & Regards,
Kumar66
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DB2 is storing the format 011010101010100100101001010111010010110101010001000

You can change the display characteristics of your viewing tool if you want it to be displayed differently from default.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kumar66 wrote:But DB2 is storing the date formt as 13-Jan-2010 10:12:34 AM.
No, it is not. A timestamp is a timestamp is a timestamp, it is your query tool that is enforcing the external format of that timestamp when you select it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply