Date conversation

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
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Date conversation

Post by srini.dw »

Hi,

My Source column all are Integer
Target column is Date (format)

My incoming values are like MONTH, DAY, YEAR. (3 different inputs)

Iam giving like MONTH : "/" DAY : "/" YEAR

I want the output as 12/31/2008, its giving error

Any ideas, please

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

Post by ray.wurlod »

You are generating a string, not a date. You need to apply a StringToDate() conversion - with appropriate format string - to the result that your concatenation expression generates.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Post by srini.dw »

I tried the option like
StringToDate(MONTH : "/" DAY : "/" YEAR), "mmm/dd/yyyy"), but in vain
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

the format string has to match exactly, if you are doing an implicit conversion of month 2 to a string you get '2', which isn't the format '02' which the conversion requires. I don't thnk that the builtin conversions put leading zeroes in and don't have the docs handy to check. But do something like:

Code: Select all

StringToDate(Right('00:MONTH,2) : "/" : right('00':DAY,2) : "/" :  Right('0000':YEAR,4), "%mm/%dd/%yyyy")
Last edited by ArndW on Thu Mar 27, 2008 4:48 am, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Plus you need some token designators ("%") in the format string. For example "%mm/%dd/%yyyy".
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Nripendra Chand
Premium Member
Premium Member
Posts: 196
Joined: Tue Nov 23, 2004 11:50 pm
Location: Sydney (Australia)

Post by Nripendra Chand »

try the following expression:

StringToDate(InputColumn, "%mmm/%dd/%yyyy")

the output of this function will be in same format which is defined at your job level or project level. Just check the date format in job properties. you can define the format there to get the date in your desired format.
-Nripendra Chand
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Surely it's %mm for a numeric month?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vkhandel
Participant
Posts: 35
Joined: Wed Oct 04, 2006 12:12 am
Location: Pune

Post by vkhandel »

srini.dw wrote:I tried the option like
StringToDate(MONTH : "/" DAY : "/" YEAR), "mmm/dd/yyyy"), but in vain
your conversion function should be like -
StringToDate(MONTH : "/" : DAY : "/" : YEAR), "mmm/dd/yyyy") ...
also be cautious with the value of variable MONTH. sine you want it in 3 digits (as intepreted by format specifier "mmm"), it should always have values like "001", "012" and not just only "1" or "12"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Actually, %MMM means that the month is in 3 digit text format (i.e. "JAN","FEB")
WoMaWil
Participant
Posts: 482
Joined: Thu Mar 13, 2003 7:17 am
Location: Amsterdam

Post by WoMaWil »

What you are discussing is the look and format. You have to take into account, what kind of target you realy have?

- sequential file
- database (what smell, Informix, Access, Unidata, DB2, Oracle.....)
- Hashed File
- Universe
Wolfgang Hürter
Amsterdam
shepli
Participant
Posts: 79
Joined: Fri Dec 17, 2004 9:56 am

Post by shepli »

I thnk the problem is that two colons have missed. Insead of

Code: Select all

MONTH : "/" DAY : "/" YEAR 
it should be like this

Code: Select all

MONTH : "/" : DAY : "/" : YEAR 
Hope this helps.

shepli
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Beat me to it! I'd just spotted the same thing.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Post by srini.dw »

sorry guys for coming late,

StringToDate(Right('00':MONTH,2) : "/" : right('00':DAY,2) : "/" : Right('0000':YEAR,4), "%mm/%dd/%yyyy")

Thank you, all you guys for your support, when i execute the above statmenet it gives like 2008-02-19.

Again later i changed that by using stage variable (In.DateCol)like

In.DateCol[6,2] : "/" : In.DateCol[9,2] : "/" : In.DateCol[1,4]

StageVar[6,2] : "/" : StageVar[9,2] : "/" : StageVar[1,4]

Thank you
Post Reply