Hello,
I'm creating a select-query to get the data of a specific month of every year.
So not just one month, but all the months december of 2006, 2007, 2008, ...
How do I do that?
Select a month of every year
Re: Select a month of every year
You can just compare the month part of the date-field.
But it is different on every Database Management System.
In MySQL, you can use something like this:
more info: http://dev.mysql.com/doc/refman/5.7/en/ ... tions.html
On SQL-server:
More info : http://www.w3schools.com/sql/func_datepart.asp
I don't have much experience with PostgresSQL, Oracle and others;
But they probably have something similar.
But it is different on every Database Management System.
In MySQL, you can use something like this:
Code: Select all
SELECT date,otherfields FROM table WHERE month(date)=12;
On SQL-server:
Code: Select all
SELECT date,otherfields FROM table WHERE DATEPART(mm,date)=12;
I don't have much experience with PostgresSQL, Oracle and others;
But they probably have something similar.