View Full Version : Date problem
03-24-2009, 11:57 AM
Hi, i am writing an php program that will write the date to MySQL. the table has a date column with type "date". when I insert the data, e.g. "2009-03-24" to the table, the query was sucessful but i got this data "0000-00-00" instead. could anyone helps me what is the problem?? thanks!
03-24-2009, 01:48 PM
can you show us your create table statement and your insert statement?
03-25-2009, 11:07 AM
i create the table by
create table date_test(
did, int not null primary key auto_increment,
dateData, date not null)
adding data by
insert into date_test (dateData) values (2009-03-24)
i am using a wamp 5 as my testing server. i guess something wrong with the MySQL configuration. please give me a hand, thx!!
03-25-2009, 03:07 PM
your problem is how you are inserting your date, you need a set of single or double quotes around it. If you don't then it thinks you are doing a mathematical computation (i.e. subtracting 2009 minus 3 minus 24. That would then end up with an incorrect value for a date column. It should give you an error message (it does on mysql 5.0.67), but may change it to 0000-00-00 on an older version of mysql.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.