Convert timestamp to MMDDCCYYHHMMSS

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

Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Convert timestamp to MMDDCCYYHHMMSS

Post by Marley777 »

:)

Hi, thanks for reading. How can I convert a timestamp to MMDDCCYYHHMMSS? Thanks!!
mallikarjuna36
Premium Member
Premium Member
Posts: 12
Joined: Mon Oct 22, 2007 7:58 am

Re: Convert timestamp to MMDDCCYYHHMMSS

Post by mallikarjuna36 »

please read pallelextender pdf document.
mallikarjuna36
Premium Member
Premium Member
Posts: 12
Joined: Mon Oct 22, 2007 7:58 am

Re: Convert timestamp to MMDDCCYYHHMMSS

Post by mallikarjuna36 »

please read pallelextender pdf document.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

I read the PX PDF, but still trying to find a specific example. I trying to simply take CurrentTimestamp and convert it to MMDDCCYYHHMMSS.

:oops:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Best to specify what the exact format is that you need to convert it from would be.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Thanks for reading.

I'm trying to take the date suplpied by the DataStage CurrentTimestamp() function within a transformer derivation and convert it to MMDDCCYYHHMMSS.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Doesn't answer the question - what format is that in? You need to know that in order to know how to 'convert' it...
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Doesn't answer the question - what format is that in? You need to know that in order to know how to 'convert' it...
-craig

"You can never have too many knives" -- Logan Nine Fingers
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

For a timestamp the format is %yyyy-%mm-%dd %hh:%nn:%ss, but I need to convert to %mm-%dd-%yyyy %hh:%nn:%ss

Thanks
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

I going to try this, but there may be a better way. Can anyone think of a better approach?


DateToString(CurrentDate(),"%mm-%dd-%yyyy") : CurrentTime()
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Actually I'm going to try this instead


StringToTimestamp(DateToString(CurrentDate(),"%mm-%dd-%yyyy"),"%mm-%dd-%yyyy-%hh.%nn.%ss")


Is there a better way? Thanks!!!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you already have a timestamp, which I infer from your original post in this thread, simply convert it to a string, then use substring and concatenation to build the new format. Converting all the internal delimiters to "" first will make this easier.

Assign stage variable svTS with

Code: Select all

Convert(" ;-", "", TimestampToString(InLink.TheTimestamp))
Build your output column as

Code: Select all

svTS[5,2]:svTS[7,2]:svTS[1,4]:svTS[9,6]
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you already have a timestamp, which I infer from your original post in this thread, simply convert it to a string, then use substring and concatenation to build the new format. Converting all the internal delimiters to "" first will make this easier.

Assign stage variable svTS with

Code: Select all

Convert(" ;-", "", TimestampToString(InLink.TheTimestamp))
Build your output column as

Code: Select all

svTS[5,2]:svTS[7,2]:svTS[1,4]:svTS[9,6]
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Or, just change the timestamp mask to whatever you want in the output stage by going to the extended properties. The date is stored internally. It could be displayed however you want, which is determined by the mask that is supplied at the project level, set in the administrator. To override that, change it in the extended properties of your column in your target stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

Thanks to everyone for you help.

Hi DSguru2B, it looks like the sequential file stage gives me the option to override the timestamp default. It's on the format tab in the sequntial file stage. Is this what you were thinking too? Thanks!!
Post Reply