Date_from_string Warnings

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
Lotus26
Premium Member
Premium Member
Posts: 48
Joined: Tue Jul 13, 2004 2:09 pm

Date_from_string Warnings

Post by Lotus26 »

HI

I am using StringToDate funtion in a transformer (Parallel job)

if Out_rdmNdcLstRun_seq.END_DATE="" then "" else StringToDate(Trim(Out_rdmNdcLstRun_seq.END_DATE),"%yyyy-%mm-%dd")

But I am getting warnings like

Conversion error calling conversion routine date_from_string data may have been lost

I checked my data and my date values are in the format of 9999-12-31 and I don't have any null values . Even then I am getting warnings like that .

Can anybody help me in fixing that . I would appreciate any input .

Thanks.
Regards
Lotus26
jwilliams
Participant
Posts: 10
Joined: Wed Aug 15, 2007 6:53 am
Location: Tennessee, USA

Post by jwilliams »

I can't be sure because I'm not close to a box I can try it out on, but I think you may need to find a way to escape your hyphens... Perhaps by using quotes around them?
Best,
J
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

try this
if Trim(Out_rdmNdcLstRun_seq.END_DATE)="" then "" else StringToDate(Trim(Out_rdmNdcLstRun_seq.END_DATE),"%yyyy-%mm-%dd".

what is the default date format in your project/job. if you have not changed then i must be yyyy-mm-dd only.

then try this code

if Trim(Out_rdmNdcLstRun_seq.END_DATE)="" then "" else Trim(Out_rdmNdcLstRun_seq.END_DATE)
dspxlearn
Premium Member
Premium Member
Posts: 291
Joined: Sat Sep 10, 2005 1:26 am

Post by dspxlearn »

can you check if that this field doesn't have null values and from the source it is defined as Not nullable and it is of varchar/char datatype?
Remove the 'Trim' function on 'Out_rdmNdcLstRun_seq.END_DATE'
Modify the code :
from:
if Trim(Out_rdmNdcLstRun_seq.END_DATE)="" then "" else StringToDate(Trim(Out_rdmNdcLstRun_seq.END_DATE),"%yyyy-%mm-%dd".

To:

If Trim(col) <> '' Then StringToDate(col,"%yyyy-%mm-%dd") Else ''

let see if the resolves the issue
Thanks and Regards!!
dspxlearn
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

What is your source and target nullability?

If your target is nullable yes, then

if Trim(Out_rdmNdcLstRun_seq.END_DATE)="" then @NULL else StringToDate(Trim(Out_rdmNdcLstRun_seq.END_DATE),"%yyyy-%mm-%dd")

If your target is nullable no then you will have to give some default value for date. like

if Trim(Out_rdmNdcLstRun_seq.END_DATE)=""
then
StringToDate("0000-00-00","%yyyy-%mm-%dd") else StringToDate(Trim(Out_rdmNdcLstRun_seq.END_DATE),"%yyyy-%mm-%dd")
Post Reply