tags:

views:

26

answers:

4
+3  Q: 

date change in sql

hi I have a date which is 2009-06-02 00:00:00.000 and i want to only group by month ..

how can change it ?!

A: 

use

group by MONTH(record_date)

see this question for more information :

http://stackoverflow.com/questions/508791/mysql-query-group-by-day-month-year

Haim Evgi
Note that this'll require the MONTH() function to be executed against every row in the table every time it's requested...
ceejayoz
ops sorry month and year without the day !!
i add a link to similar question that support this
Haim Evgi
A: 
SELECT ... GROUP BY MONTH(datecolumn)
Yada
+2  A: 

You may want to group by month, but have data that spans more than one year. In that case, I would do:

group by Year(MyDate), Month(MyDate)
RedFilter
A: 
GROUP BY MONTH(yourdate)

Also check out Date and Time Function: Month

kevchadders
i want it in the select !! like select vender month and year of the duedate ... the duedate is a full daye like 2009-06-02 00:00:00.000