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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 1:15 pm
Hi, thanks for reading. How can I convert a timestamp to MMDDCCYYHHMMSS? Thanks!!
Marley777
Premium Member
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 2:12 pm
I read the PX PDF, but still trying to find a specific example. I trying to simply take CurrentTimestamp and convert it to MMDDCCYYHHMMSS.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Oct 23, 2007 2:15 pm
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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 2:20 pm
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
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Oct 23, 2007 2:21 pm
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
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Oct 23, 2007 2:23 pm
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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 2:24 pm
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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 2:35 pm
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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Tue Oct 23, 2007 2:47 pm
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 » Tue Oct 23, 2007 4:01 pm
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 » Tue Oct 23, 2007 4:03 pm
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
Posts: 6854 Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX
Post
by DSguru2B » Tue Oct 23, 2007 4:17 pm
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
Posts: 316 Joined: Tue Jan 27, 2004 3:26 pm
Post
by Marley777 » Wed Oct 24, 2007 5:19 am
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!!