MySQL Forums
Forum List  »  French

Re: Différence de comportement de la fonction NOW()
Posted by: Francis Besset
Date: August 26, 2009 02:29PM

Pour ceux qui ne cerne pas très bien le problème voici un log de requête SQL sur MySQL version 5.0.32 et la version 5.0.51a.


VERSION 5.0.32 :
Your MySQL connection id is 6
Server version: 5.0.32-Debian_7etch8-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database deb;
Query OK, 1 row affected (0.00 sec)

mysql> use deb;
Database changed
mysql> CREATE TABLE `compte` (
-> `date_compte` date NOT NULL,
-> UNIQUE KEY `date_compte` (`date_compte`)
-> );
Query OK, 0 rows affected (0.01 sec)

mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2009-08-26 21:55:35 |
+---------------------+
1 row in set (0.00 sec)

mysql> insert into compte (`date_compte`) values ( "2009-08-26");
Query OK, 1 row affected (0.01 sec)

mysql> select * from compte where `date_compte`="2009-08-26";
+-------------+
| date_compte |
+-------------+
| 2009-08-26 |
+-------------+
1 row in set (0.00 sec)

mysql> select * from compte where `date_compte`=NOW();
+-------------+
| date_compte |
+-------------+
| 2009-08-26 |
+-------------+
1 row in set (0.00 sec)

mysql> drop database deb;
Query OK, 1 row affected (0.01 sec)

mysql> quit
Bye



VERSION 5.0.51a :
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 258
Server version: 5.0.51a-19 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database deb;
Query OK, 1 row affected (0.00 sec)

mysql> use deb;
Database changed
mysql> CREATE TABLE `compte` (
-> `date_compte` date NOT NULL,
-> UNIQUE KEY `date_compte` (`date_compte`)
-> );
Query OK, 0 rows affected (0.00 sec)

mysql> insert into compte (`date_compte`) values ( "2009-08-26");
Query OK, 1 row affected (0.00 sec)

mysql> select * from compte where `date_compte`="2009-08-26";
+-------------+
| date_compte |
+-------------+
| 2009-08-26 |
+-------------+
1 row in set (0.00 sec)

mysql> select * from compte where `date_compte`=NOW();
Empty set (0.00 sec)

mysql> drop database deb;
Query OK, 1 row affected (0.00 sec)

mysql> quit
Bye

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Différence de comportement de la fonction NOW()
3208
August 26, 2009 02:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.