...

View Full Version : Field type problem



xiaodao
02-08-2006, 10:07 AM
i set field"start date" as DATE

but when i enter date formate like 2006-10-28
YYYY-MM-DD format
the data cannot be entereed

0000-00-00 is recorded
what happens

raf
02-08-2006, 11:00 AM
are you talking about MySQL? Wrong Forum?

maybe we can see some code? maybe the query? maybe a description of that table?

raf
02-08-2006, 11:00 AM
-----------------

xiaodao
02-08-2006, 12:09 PM
HI,
my database


CREATE TABLE mw_test(
id INT(15) AUTO_INCREMENT NOT NULL,
todaydate DATE,
PRIMARY KEY(id)
)


Then i do one mysql insert


$sql=$db->query("INSERT INTO mw_test VALUES(NULL,'2006-10-22')");


then you check the phpmyadmin you will discover that the inserted todaydate is 0000-00-00
very strange

raf
02-08-2006, 12:33 PM
try changing your query to

sql=$db->query("INSERT INTO mw_test (todaydate) VALUES('2006-10-22')");

or run this inside the phpMyAdmin querywindow:
INSERT INTO mw_test (todaydate) VALUES('2006-10-22')

xiaodao
02-08-2006, 02:57 PM
can i enter value like DD-MM-YYYY

raf
02-08-2006, 03:02 PM
you can try, and MySQL will try to interpret it, but there is no guarantee that this interpretation will be correct. For instance, should 01-02-2005 be the first of februari or the second januari?
MySQL doesn't realy have a way of telling that, so it's not a good idea.

Did you try the suggestions i posted + what was the result?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum