Page 1 of 2

Convert timestamp to MMDDCCYYHHMMSS

Posted: Tue Oct 23, 2007 1:15 pm
by Marley777
:)

Hi, thanks for reading. How can I convert a timestamp to MMDDCCYYHHMMSS? Thanks!!

Re: Convert timestamp to MMDDCCYYHHMMSS

Posted: Tue Oct 23, 2007 1:41 pm
by mallikarjuna36
please read pallelextender pdf document.

Re: Convert timestamp to MMDDCCYYHHMMSS

Posted: Tue Oct 23, 2007 1:42 pm
by mallikarjuna36
please read pallelextender pdf document.

Posted: Tue Oct 23, 2007 2:12 pm
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:

Posted: Tue Oct 23, 2007 2:15 pm
by chulett
Best to specify what the exact format is that you need to convert it from would be.

Posted: Tue Oct 23, 2007 2:20 pm
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.

Posted: Tue Oct 23, 2007 2:21 pm
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...

Posted: Tue Oct 23, 2007 2:23 pm
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...

Posted: Tue Oct 23, 2007 2:24 pm
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

Posted: Tue Oct 23, 2007 2:35 pm
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()

Posted: Tue Oct 23, 2007 2:47 pm
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!!!

Posted: Tue Oct 23, 2007 4:01 pm
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]

Posted: Tue Oct 23, 2007 4:03 pm
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]

Posted: Tue Oct 23, 2007 4:17 pm
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.

Posted: Wed Oct 24, 2007 5:19 am
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!!