Page 1 of 1

Comparing date fields

Posted: Wed Dec 17, 2008 1:21 am
by swathi Singamareddygari
Hi all,

I am facing an issue when comparing date fields.

I am doing like this

If Lkp_Read.EFF_DT_Target=Lkp_Read.EFF_DT_Input then 'I' Else 'U'

Lkp_Read.EFF_DT_Target,Lkp_Read.EFF_DT_Input are two nullable date fields.

If null is coming its giving warning as

Tfm_2,0: Conversion error calling conversion routine date_from_ustring data may have been lost

i tried using NULLToValue function also for assigning '' to date field but its not assigning empty to date field.

Please help me in this one

Thanks for your help

Regards

Swathi S

Re: Comparing date fields

Posted: Wed Dec 17, 2008 3:08 am
by Jasti
swathi Singamareddygari wrote: i tried using NULLToValue function also for assigning '' to date field but its not assigning empty to date field.
Swathi S
Try to pass all 0(zero) s into the date field in the correct date format which is used in you job,if the date field contains a null..

Posted: Wed Dec 17, 2008 3:20 am
by LenGreenwood
You have to decide what date you would substitute for a null value. For strings, the empty string ("") is an obvious choice for null, and for numbers 0 is fairly obvious. But for dates you need to pick something like "1900-01-01" if you really must treat null as if it were a default value. date_from_ustring() will only work on a valid date in the string, and "" is not a valid date format.

So try using NullToValue(link.col,"1900-01-01")

(Of course you also need to consider why the values are coming as null in the first place, as in SQL there is a distinction between "" and 0 and null.)