Date Manipulation

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
ppp
Participant
Posts: 21
Joined: Mon Aug 31, 2009 11:53 am

Date Manipulation

Post by ppp »

I have input data which is numeric and stored in 4 different fields as follows.


Century : 20
Year : 9
Month : 1
Day : 5

This data has to be formatted to arrive at the date in the format
2009-01-05 or 2009-01-05-HH.MM.SS.NNNNNN

How can I achieve this?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What is your target? Database table? If so, what data type? I ask because of your "has to arrive in X format" statement, that won't be true for an actual Date field.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ppp
Participant
Posts: 21
Joined: Mon Aug 31, 2009 11:53 am

Post by ppp »

My target is a flat file and it is varchar.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

(Century*100 + Year) : '-' : right('00':Month,2) : '-' : right('00':Day,2)
You are the creator of your destiny - Swami Vivekananda
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

OK, then just assemble the pieces. FullYear = (Century*100)+Year. Month and Day append a '0' when Len = 1. Cat together with your delimiter.
-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 »

I was going to let them work out the gory details, but... there you go. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Nobody, not even the OP, has addressed how the time component has to be created.
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 »

I specifically left it off as it seemed to be optional and since there seemed to be no actual time component incoming...
-craig

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