Tmestamp to date 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
senthilt1
Participant
Posts: 134
Joined: Mon Nov 19, 2007 2:17 am

Tmestamp to date conversion

Post by senthilt1 »

HI All,

I want to convert the timestamp inp date to date type in output with the following format,

Inp:

2010-02-10 02:30:40

Ouput i Need with date as datatype:

20100210

Using functions Timestamptodate and datetostring, i got 20100210 in the output but as string, when i give the datatype Date it includes hypen '-' in the date.

Can you please suggest your view on this.

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

Post by ArndW »

Binary data types such as numbers, dates and timestamps have no internal format. Formatting is applied only when converting from another data type on input or output.

So the important question is what is your output (sequential file or database) and what is the datatype defined as in the target. Note that a text file doesn't have a Date or Time datatype but uses strings only and thus an implicit conversion from your internal datatype to the display one is done and you can specify your "YYYYMMDD" on output.
senthilt1
Participant
Posts: 134
Joined: Mon Nov 19, 2007 2:17 am

Post by senthilt1 »

Thanks ArndW,

My target is database and the datatype we need is DATE. But the value to this should be like "20100210" without hypen.

Is this possible?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

No, this is not possible. A database DATE column has no format.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Date datatype is internally represented in each database.

What you mentioned is the display format. Nothing to do with load.
senthilt1
Participant
Posts: 134
Joined: Mon Nov 19, 2007 2:17 am

Post by senthilt1 »

Ok, Thanks for the confirmation.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The apparent format of dates, times and timestamps is determined by default via settings in the Administrator client. These can be overridden in jobs and even in functions such as StringToDate().
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