Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Criteria - Date Ranges 2

Status
Not open for further replies.

cob5

Technical User
Nov 19, 2001
5
0
0
US
I have a query that currently requires manual input of the first and last day of the month to execute the query (i.e. dec-01-01 and dec-31-01). Does anybody know how I can add a criteria (I know zero about SQL or codes) that automatically makes it Between first AND last days of the current month. I currently have to remember to change it at the start of every month but I would rather have an automated process. Any ideas??
 
have them enter the numeric month and use Month([the date field]) = <the value supplied> in your where clause
 
Sorry I wasn't more specific. On the main Form of the database, there are several options available to management to run different reports. For the reports to pull accurate information, the criteria set in the query has to be
Between Dec-01-01 AND Dec-30-01.(or whatever month we are currently in)
The date peramater has to match whatever current month we are in, so that when January comes along the criteria will automatically know to use the range of Jan 1 - Jan 31.
So ideally the criteria would be like:
Between first day of current month AND last day of current month.
Management does not want to have to input date ranges so I have to come up with the solution.
HELP
 
Then you should use
WHERE Month([the date field]) = Month(Date())
 
You would also probably need to include the year in there as well to make sure your just getting values for the month of this year

WHERE Month([the date field]) = Month(Date()) And Year([the date field]) = year(Date()) Mark

The key to immortality is to make a big impression in this life!!
 
Well caught sir. I started out with nothing, and I still have most of it.
 
Hi, I'm learning sql queries and I got a problem with this of date ranges, I'm working with VB6 and access databases, I've tried to make a query to select dates before today like &quot;select date from dates where date < 'today'&quot; and it sends me an error, I've wrote that on the recordsource property of the data control, am I correct?, please I need Help, thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top