Filtering Dates in Query

Smurfit-Stone

Active Member
Joined
Dec 1, 2004
Messages
485
Hello Board, I'm trying to create a filter in a query for a date field. The field is formatted as a short date, i.e. 00/00/0000. I'd like to query on the month only. Example...I'd like to filter all dates in February. I've tried the Month(2) function and even the MonthName(2[,Feb]) and nothing seems to work. If I query ---Like "02" I get everythin in 2002, so why can't I get everything in a particular month? Please help. I need to query on Birthdays for a whole month no matter what year they were born in. Thanks in advance Board.

Saved By Grace
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi, this can defintely be done. Add the date to your query twice, on the first date change the field "date" to this :

Expr1: Month([date])

and in the criteria section under this modified field enter the value 2.

Save and run. Add additional fields as required and be sure to use your actual variable names.

The SQL for just the dates looks like this (if you want it) :

SELECT Month([date]) AS Expr1, dates_table.date
FROM dates_table
WHERE (((Month([date]))=2));

HTH, Andrew :)
 
Upvote 0
Andrew, you terrific....it works like a charm. Thanks a million. I've been trying all kinds of stuff all morning. Thanks Again


Terylgirl
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,404
Members
451,762
Latest member
Brainsanquine

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top