Benss
Benss

Reputation: 315

How to select a data access database filtering with the months of the date?

I want to select the row of a database when the month of a date is accurate. for the year I did it: select * from table where YEAR(date)='2015' it works well for the years

for the months I made :

select * from table where Month(date)='01'// I have the date format dd/mm/yyyy

thanks

Upvotes: 0

Views: 1868

Answers (2)

Soner Gönül
Soner Gönül

Reputation: 98740

From MONTH FUNCTION;

The Microsoft Access Month function returns the month (a number from 1 to 12) given a date value.

You should check it with an integer, not a string like;

select * from table where Month(date) = 1

Upvotes: 1

Mairaj Ahmad
Mairaj Ahmad

Reputation: 14604

Try this

 select * from table where Month(date)='01' and YEAR(date)='2015'

Upvotes: 0

Related Questions