This is a discussion on date format trouble within the MySQL forums, part of the Database Server Software category; --> > SET start_date=STR_TO_DATE(@date_as_string,'%m/%d/%y'); Dates have 4 digits in your data, right? %y and %Y are different. gordon/(none)> select str_to_date('11/29/1999', ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > SET start_date=STR_TO_DATE(@date_as_string,'%m/%d/%y'); Dates have 4 digits in your data, right? %y and %Y are different. gordon/(none)> select str_to_date('11/29/1999', '%m/%d/%y'); +---------------------------------------+ | str_to_date('11/29/1999', '%m/%d/%y') | +---------------------------------------+ | 2019-11-29 | +---------------------------------------+ 1 row in set, 1 warning (0.00 sec) gordon/(none)> show warnings; +---------+------+----------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------+ | Warning | 1292 | Truncated incorrect date value: '11/29/1999' | +---------+------+----------------------------------------------+ 1 row in set (0.00 sec) gordon/(none)> select str_to_date('11/29/1999', '%m/%d/%Y'); +---------------------------------------+ | str_to_date('11/29/1999', '%m/%d/%Y') | +---------------------------------------+ | 1999-11-29 | +---------------------------------------+ 1 row in set (0.01 sec) >This gets to examine the data, so I guess the syntax is OK. But I >still get an error about the date. This time, the error is "Truncated >incorrect date value: "11/22/1999" %Y and %y are different. >instead of trying to load it into @var1? Do the names in the list in >the LOAD DATA statement have to be provided in the order the >corresponding columns were created in the table? I doubt it. That would make listing the names rather pointless. >If not, I can load >the data first, and that with the data going into a column of type >char[10], and then run an UPDATE statement in which the SET start_date >clause above is invoked. Right? Yes. But fix your format first. Gordon L. Burditt |