Date format for Stringtodate()

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
bala_135
Premium Member
Premium Member
Posts: 156
Joined: Fri Oct 28, 2005 1:00 am
Location: Melbourne,Australia

Date format for Stringtodate()

Post by bala_135 »

Hi,

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,
Bala.
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

How can a date be in such a format..dmmyyyy :roll:

From first look, your date format looks like a Julian date.(dddyyyy) where ddd is the nth day of that year. Use the Date and Time Functions in the Transformer and convert it into the format you need.

IHTH
Kris

Where's the "Any" key?-Homer Simpson
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What happens if the day number is greater than 9?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
rkdatastage
Participant
Posts: 107
Joined: Wed Sep 29, 2004 10:15 am

Post by rkdatastage »

hi

Check the date size , i hope that you are having a clear idea that in general date format is DD-MM-YYYY as its size is of 8 characters , but in your requirement you had specified as 7 characters where we will get a problem when the the give date is of 2 digit length .

RK
syed_subhaan
Participant
Posts: 8
Joined: Sat Apr 22, 2006 2:28 am
Location: Bangalore
Contact:

Date format

Post by syed_subhaan »

kris007 wrote:How can a date be in such a format..dmmyyyy :roll:

From first look, your date format looks like a Julian date.(dddyyyy) where ddd is the nth day of that year. Use the Date and Time Functions in the Transformer and convert it into the format you need.

IHTH
Hi,
I agree with krish.
it looks like a julian date.
Thanks & Regards,
Subhani Basha Syed.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

So that 1052003 is the 105th day of the year 2003. The correct date format string would be "%ddd%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.
Post Reply