List:General Discussion« Previous MessageNext Message »
From:(Roberta Jask Date:July 24 2012 5:36pm
Subject:Re: YEAR and time types
View as plain text  
>>>> 2012/07/24 08:46 -0700, Hassan Schroeder >>>>
On Mon, Jul 23, 2012 at 5:58 AM,  <hsv@stripped> wrote:

> I thought I would try YEAR to record it--but, in spite of
> http://dev.mysql.com/doc/refman/5.5/en/year.html , simply assigning NOW() to such a type
> does not work.

Not sure I understand the issue:

mysql> create table babble (sometime year(4));
Query OK, 0 rows affected (0.13 sec)

mysql> show create table babble;
+--------+------------------------------------------------------------------------------------------------+
| Table  | Create Table
                                   |
+--------+------------------------------------------------------------------------------------------------+
| babble | CREATE TABLE `babble` (
  `sometime` year(4) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+--------+------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into babble values ( NOW() );
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> select * from babble;
+----------+
| sometime |
+----------+
|     2012 |
+----------+

??
<<<<<<<<
Well, let me show this:

 version(): 5.5.8-log
@@sql_mode:
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_DATE,ALLOW_INVALID_DATES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

What is yours?

Thread
YEAR and time typeshsv23 Jul
  • RE: YEAR and time typesRick James23 Jul
    • RE: YEAR and time typeshsv24 Jul
Re: YEAR and time typeshsv24 Jul
Re: YEAR and time typeshsv30 Jul