List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:September 2 1999 7:26pm
Subject:can NOW() be inserted into DATETIME?
View as plain text  
>>>>> "Stan" == Stan P van de Burgt <stan@stripped> writes:

Stan> Hi
Stan> I wonder if the value of NOW() can be inserted safely into a type DATETIME 
Stan> column.
Stan> Consider the commands below:

mysql> describe log;
Stan> +--------+----------------------+------+-----+---------------------+-------+
Stan> | Field  | Type                 | Null | Key | Default             | Extra |
Stan> +--------+----------------------+------+-----+---------------------+-------+
Stan> | uid    | int(5) unsigned      |      | MUL | 0                   |       |
Stan> | qid    | int(5) unsigned      |      |     | 0                   |       |
Stan> | stamp  | datetime             |      |     | 0000-00-00 00:00:00 |       |
Stan> | action | smallint(3) unsigned |      |     | 0                   |       |
Stan> +--------+----------------------+------+-----+---------------------+-------+
Stan> 4 rows in set (0.05 sec)

mysql> INSERT INTO log SET stamp=NOW();
Stan> Query OK, 1 row affected (0.00 sec)

mysql> SELECT qid , TO_DAYS(stamp),stamp FROM log;
Stan> +-----+----------------+---------------------+
Stan> | qid | TO_DAYS(stamp) | stamp               |
Stan> +-----+----------------+---------------------+
Stan> |   0 |           NULL | 1999-09-02 +2:32:64 |
Stan> +-----+----------------+---------------------+
Stan> 1 row in set (0.00 sec)

mysql> 


Stan> There's something strange with the value in the 'stamp' column. It should 
Stan> read 12:32:64.
Stan> The TO_DAYS function doesn't seem to like the value either as it displays NULL.

Hi!

Could you please repost with your mysqlbug;  I would need to know a
little more about your MySQL version to be able to answer this!

By the way, does it work if you insert "1999-09-02 12:32:64" ?

Note that 3.23.2 has a new faster handling of all time functions;
If you have 3.23.2 this may be the problem, even if works for me:

mysql> create table t1 (d datetime );
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values (now());
Query OK, 1 row affected (0.03 sec)

mysql> select * from t1;
+---------------------+
| d                   |
+---------------------+
| 1999-09-02 22:23:41 |
+---------------------+
1 row in set (0.00 sec)

Regards,
Monty
Thread
can NOW() be inserted into DATETIME?Stan P. van de Burgt2 Sep
  • can NOW() be inserted into DATETIME?Michael Widenius3 Sep