MySQL Forums
Forum List  »  Newbie

CSV to MySQL
Posted by: Jim Sawyer
Date: February 09, 2016 04:43PM

I am converting a csv file to MySQL. One of the columns is a data. I am converting the DATE1 varchar(10) field to Date2 date field. I am using

update MyTable
set DATE = NULL;
update MyTable
set
DATE2 = STR_TO_DATE(DATE1,'%m/%d/%Y')
where
DATE1 is not NULL;

This works fine until I run across the occasional DATE! value of "H" or some other random thing that client's manage to pry into data. I would like for it to treat every DATE1 value that is not a valid date format as if it were NULL. Is there any way to handle these cases as exceptions where it will just skip them?

I'm new to MySQL and would appreciate some help.

Thanks,
Jim Sawyer

Options: ReplyQuote


Subject
Written By
Posted
CSV to MySQL
February 09, 2016 04:43PM
February 09, 2016 08:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.