sqlmysql

Selecting data from table based on date


I have a database table that looks like this:

+-------+--------------+----------+
|   id  |    ip        |    date  |
+-------+--------------+----------+
|   505 |192.168.100.1 |2010-04-03|
|   252 |192.168.100.5 |2010-03-03|
|   426 |192.168.100.6 |2010-03-03|
|   201 |192.168.100.7 |2010-04-03|
|   211 |192.168.100.10|2010-04-03|
+-------+--------------+----------+

How can I retrieve data from this table where month=03 - how to write a SQL query to do that?

select * 
from table 
where month = 03 

something like that.


Solution

  • If using mysql, use the MONTH() function I think.

    select * from table where month(date) = 3