Month return

Pete Morris

Registered User.
Local time
Today, 19:55
Joined
Mar 31, 2003
Messages
38
I have a date field. I have a query which runs between start and end date, but obviously requires the dates to be typed in. Can I set up this query so that I only have to type in the No of the month say 8 for it to return all the records in August?
 
You can, but then if you have records over a couple of years you would get all records in Augusr for 2001, 2002, 2003, etc.


Esssentially, though, what you want is the Month() function.
 
so is the best option to stick with the between dates?
 
Here's an example of a parameter query that asks for month & year in mm/yyyy format then uses that to calculate the first and last day of the month. You can test it in Northwind.
Code:
PARAMETERS [enter mm/yyyy] Text;
SELECT Orders.OrderID, Orders.OrderDate
FROM Orders
WHERE (((Orders.OrderDate) Between DateValue([enter mm/yyyy]) And DateAdd("m",1,DateValue([enter mm/yyyy]))-1));
It's a little more than just specifying a month, but certainly less labor intensive than keying in actual dates.

HTH-
Bob
 

Users who are viewing this thread

Back
Top Bottom