How to add date criteria to query in Access 2007?
Hi, I'm using Access 2007 for an information systems homework assignment and I'm a little stumped on one of the steps. (Also please keep in mind I'm extremely unfamiliar with access, so if you could break it down as simply as possible it would be greatly appreciated).
Basically, my problem is sorting by a date in one of my queries. I have a query named January2012, and I'm supposed to only show the entries that are in the month of January in 2012. The format is in a "3/20/12" format. I'm not sure where I'm supposed to go and what I'm supposed to type so that way I only see the ones that are in January (1). Keep in mind there are only January, February and March 2012 entries in the query, so there are no other months or years. I apologize if this question is a little confusing, but any help at all would be greatly appreciated!
Comments
Go into the query design. Add the field that contains the dates to your query. Do you understand how to do that part? The simplest way of course is to do it during query design but if you didn't then you can either double click on the date field or else click once on it and drag it down.
Once you get the date field in, then click into the box beside "Criteria" in this date field column. This is the formula you need for showing only Jan 12 dates:
>#12/31/2011# And <#2/1/2012#
The # sign is what you use with dates in a criteria requirement always for dates. The > means greater than and < means less than. Thus, the criteria above means in language:
Show me all dates that are greater than Dec 31, 2011 and less than Feb 1, 2012 (ergo: give me all of Jan 12 dates)
Good luck
It relies upon on what you gave the date constraint. Did you employ smalldatetime? date? datetime? finding on what you used as date the equipment will additionally throw interior the time, usually a nil:00:00.000 at the back of the date besides to compenstate the time on that date.
it should work this way if i understand the given requirements.
SELECT customer.*, Format([created_on],"mm/yyyy") AS formatted_created_on
FROM customer
WHERE (((Format([created_on],"mm/yyyy")) = "01/2013"))
ORDER BY Format([created_on],"mm/yyyy");