MySQL Date question (Full Version)

All Forums >> [Web Development] >> ASP, PHP, and Database



Message


sentinel -> MySQL Date question (6/12/2009 11:18:06)

Hey all....

I am using mysqlimport to push a .csv file into a table. The table data looks like this.

6/11/09,1281104,324,313,11,0,96

The problem I have is after the import is completed the data is wrong in the table.

6/11/09 show up like this: 0006-11-09.

I understand that it is due to mysql default date setup as yyyy-mm-dd. Is there a way to change this on mysql for the datefield in question?

Thanks,

Rich




womble -> RE: MySQL Date question (6/14/2009 10:13:22)

Check out the MySQL manual, which can be found in various places online, inlcuding here (the definitive source), for whichever version of MySQL your server's running. The manual's huge (but it is divided up into sections), and there's a section on data formats - IIRC it's chapter 10 on the different data types, and there's a section on formatting dates and times.

It's a while since I've done anything with MySQL involving dates so I can't remember offhand exactly how it's done with the specifiers (of which there are loads, but they're all listed in the MySQL manual), but you should be able to use "DATE_FORMAT()" to format the date how you want it. Your year in the data's best in the four letter format though because MySQL will interpret two-digit ambiguous dates assuming that 00 to 69 is in this century (i.e. the 21th century, so it'd interpret 14/06/09 as 14/06/2009, but 70 to 99 as being in the 20th century - so it'd interpret 14/06/71 as 14/06/1971, which might be fine now using a two-digit year, but could cause problems further down the line.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875