Reputation: 129
I have table in database which has fields -(EId,PId,Date,Time)
.
I want to select all the fields from this table where month < 5
.To be more elaborate I want entries which were entered into the table before month 5
.
Please help me write this sql query. Thanks :)
Upvotes: 0
Views: 3431
Reputation: 522712
Use MONTH()
and also remember to restrict the year in the WHERE
clause:
SELECT *
FROM yourTable
WHERE MONTH(Date) < 5 AND YEAR IN (...)
Upvotes: 1