View Single Post

   
  #2 (permalink)  
Old 03-17-2008, 06:13 AM
Michael Austin
 
Posts: n/a
Default Re: Date coding problem

Michaelp wrote:
> Hello!
>
> In a database I would like to code a type of event, for which I
> sometimes have a full date for, and at other times only the year.
>
> Is there a way to insert a year into a MySQL date column, in a normal
> date format and that, in a standard way, expresses that "for this
> specific event I only have the year"?
>
> Thanks
>
> Michael


http://dev.mysql.com/doc/refman/5.0/...functions.html

mysql> select year(cast('2008-2-2' as datetime))as myYEAR,
cast('2008-2-2' as date) as fullDATE;
+--------+------------+
| myYEAR | fullDATE |
+--------+------------+
| 2008 | 2008-02-02 |
+--------+------------+
1 row in set (0.02 sec)

Reply With Quote