Strin to Date convertion

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
siva7143
Participant
Posts: 35
Joined: Wed Aug 09, 2006 12:20 am

Strin to Date convertion

Post by siva7143 »

my doubt is on StringtoDate() convertion .......................

My input date is 1052003(dmmyyyy).I am getting this field as a varchar field(length 7).

I want to convert this into date field(yyyy-mm-dd)

In transformer i am using the function StringToDate()

I assume StringToDate() takes only the exact date format(ie if i get the input field as 01-05-2003 then i can use the function stringtodate())
Its perfectly working fine.

My input is 1052003(dmmyyyy).So i am splitting the input value as
d in one stage variable,mm in one stage variable,yyyy in one stage varibale.

and concatenating all the three as below
Year:'-':Month:'-':Day

When i try to load this in oracle(10g) i am getting the following warning.

INSERT_AR,0: Invalid date value in getInputFieldAsDate() for field '10' of input dataset '0'.

I am assuming that the problem is with the format because i tested with a hardcoded date(2003-12-01) into the table its getting properly inserted.

Kindly let me know where i am going wrong.
Any inputs would be appreciated.

Regards,
Siva.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Your input is the not the standard date. It looks like a Julian Date. Go through the technical specifications or ask someone who knows the source data and make sure that it is a Julian Date.Then use the DataTime functions to convert it into a date suitable to your target database.
Kris

Where's the "Any" key?-Homer Simpson
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Hi Siva, Have you tried the previous suggestion?
The string fromate of "%d%mm%yyyy" should work or you can concatinate 0 to the input field to have "dd" string formate.
Like StringToDate("0":inputfield,"%dd%mm%yyyy"), this should convert into date format.
As asked you in other post, who do you manage the date with single digit?
Sometimes it can be dddyyyy, i.e., number of days since the year start.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
siva7143
Participant
Posts: 35
Joined: Wed Aug 09, 2006 12:20 am

Thanks

Post by siva7143 »

Yes i got it thanks to all.

Atlast the StringtoDate() was converted into the Oracle table.

It worked because the mistake was done in concatination.

Thanks to all.

Regards,
Siva
Post Reply