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: [email protected] [mailto:[email protected]]
> Sent: Monday, July 23, 2012 5:59 AM
> To: [email protected]
> 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
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql