Date conversion from String

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
devsonali
Premium Member
Premium Member
Posts: 155
Joined: Sun Mar 18, 2007 2:31 pm

Date conversion from String

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devsonali
Premium Member
Premium Member
Posts: 155
Joined: Sun Mar 18, 2007 2:31 pm

Post by devsonali »

Thanks Craig
But isn't the IsValidDate function expecting a date input ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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. :?
Last edited by chulett on Thu Oct 22, 2015 9:38 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
devsonali
Premium Member
Premium Member
Posts: 155
Joined: Sun Mar 18, 2007 2:31 pm

Post by devsonali »

Thanks again , That works .
Post Reply