List:General Discussion« Previous MessageNext Message »
From:Rick James Date:July 23 2012 6:54pm
Subject:RE: YEAR and time types
View as plain text  
mysql> SELECT YEAR(NOW());
+-------------+
| YEAR(NOW()) |
+-------------+
|        2012 |
+-------------+

mysql> SELECT CONCAT('2012', '-01-01');
+--------------------------+
| CONCAT('2012', '-01-01') |
+--------------------------+
| 2012-01-01               |
+--------------------------+

To show that it acts like a DATE:
mysql> SELECT CONCAT('2012', '-01-01') - INTERVAL 1 day;
+-------------------------------------------+
| CONCAT('2012', '-01-01') - INTERVAL 1 day |
+-------------------------------------------+
| 2011-12-31                                |
+-------------------------------------------+


> -----Original Message-----
> From: hsv@stripped [mailto:hsv@stripped]
> Sent: Monday, July 23, 2012 5:59 AM
> To: mysql@stripped
> Subject: YEAR and time types
> 
> A director s term ends in a given year, but at no given time of year;
> depends on the yearly meeting.
> 
> 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. There is also no implicit
> conversion to DATE. All in all, it behaves as a small integer, not a
> time type. For my end it is much less good than 'year-00-00', something
> already slightly obscure.
> 
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql

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