I need help converting a data field to datetime from a varchar(10)
I have this statement that I need to execute:
DELETE FROM callcenter..tRecipQueue WHERE DATEDIFF(dd, expiration_date, GetDate()) > 368
Of course it doesn't work because expiration_date is a varchar data type, which contains MM/DD/YYYY value. How can I efficiently cast or convert that data, so my sp won't complain about this error?
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
Thank you for confirming that it was data error!
Wow, after analyzing the data I figured it out! On my forms I was not validating the dates properly, so some how three dates were passed as 02/29/2007, 02/30/2008, which are not valid! I have three textboxes each for MM/DD/YYYY, I guess before I do an insert/update to the column I should do a validation.
I set a string variable that takes each textbox value and I string them together.
Couldn't you convert it into a date type when it goes into the database?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)