469,148 Members | 1,433 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,148 developers. It's quick & easy.

mysql 3.23 datatime problem

Sun
Hi all,

I am inserting datatime value into mysql table, while select value its
giving 0000-00-00 00:00:00 value.
mysql> insert into dtest values('02-17-05 17:08:02');
Query OK, 1 row affected (0.00 sec)

mysql> select * from dtest;

+---------------------+
| mydate |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)

mysql> desc dtest;
+--------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| mydate | datetime | YES | | NULL | |
+--------+----------+------+-----+---------+-------+
1 row in set (0.00 sec)
Any help to fix this problem.

-SR

Jul 23 '05 #1
3 1465

"Sun" <sf******@gmail.com> wrote
mysql> insert into dtest values('02-17-05 17:08:02');
Query OK, 1 row affected (0.00 sec)

mysql> select * from dtest;

+---------------------+
| mydate |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)


This works:

insert into dtest values('2005-02-17 17:08:02');

Explained under the datetime datatype in the manual...

-- Dan
Jul 23 '05 #2
Although MySQL tries to interpret values in several formats, it always
expects the year part of date values to be leftmost. Dates must be
given in year-month-day order (for example, '98-09-04'), rather than in
the month-day-year or day-month-year orders commonly used elsewhere
(for example, '09-04-98', '04-09-98').
http://dev.mysql.com/doc/mysql/en/da...ime-types.html

Hopes this helps.

Jul 23 '05 #3
Sun wrote:
mysql> insert into dtest values('02-17-05 17:08:02');


Try '2005-02-17 17:08:02'. MySQL accepts date formats only in one
format, YYYY-MM-DD.

Regards,
Bill K.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Lenz Grimmer | last post: by
3 posts views Thread by Kirk Soodhalter | last post: by
8 posts views Thread by Zibi | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.