Page 1 of 1

Date conversion from String

Posted: Thu Oct 22, 2015 8:15 am
by devsonali
Hello All,

I have a simple operation where I am converting a 8 digit varchar string into date and then validating if the date is a valid date.

So the job is dataset->transformer->dataset

The issue ; One of the input string is '09001972' (MMDDYYYY Format) , so when I first convert into date it throws the warning
"Conversion error calling conversion routine date_from_string data may have been lost"

Obviously , my next step is to validate the date and if its not valid convert it into some default .

However , The string to date conversion itself throws a warning as the date itself is invalid (but a valid string)

I am trying to get rid of this warning , but I guess I am missing something here

Appreciate your inputs on this
Thanks for looking

Posted: Thu Oct 22, 2015 8:47 am
by chulett
You've got the order backwards. First check to see if it is a valid date and then only if it is valid, convert it.

Posted: Thu Oct 22, 2015 8:52 am
by devsonali
Thanks Craig
But isn't the IsValidDate function expecting a date input ?

Posted: Thu Oct 22, 2015 9:24 am
by chulett
Yes but don't use that one. Use IsValid() with the 'Date' option. Oddly enough, they are not equivalent although it seems like they should be. There have been discussions here (that I don't recall the gory details of) about why you would want to check that a date field is actually valid when if it wasn't you wouldn't be able to put the value there. :?

Posted: Thu Oct 22, 2015 9:37 am
by devsonali
Thanks again , That works .