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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format gives wrong query information

Status
Not open for further replies.

jovuco

ISP
Oct 30, 2001
17
0
0
US
How do I either, create a date field that recognizes a 0 in front of the single digit months? Ie, 01 (January).
Or what do I need to put in the query to get a report of a specific month, that has 1 in the month.

I currently have it set up so the user puts in the month to generate a report, but when they put in 1. They get data for October through January.
Access is currently set up to eliminate the first 0, if you put in a date like 01/01/02.

Simple question, I hope, but I just don't know enough about Access to know the answer myself. Thanks.
jo
 
How are you formatting your field:

"mm/dd/yy" = 01/01/02
"m/dd/yy" = 1/01/02
"m/d/yy" = 1/1/02
etc...

If you want to search for months by integer (entering a 1 for january as opposed to the full date) then a good way to express that criteria in a query would be the following:

DatePart("m",[YourDateField]) = 1

The DatePart function will return the integer value of whatever portion of the date you are looking for (as noted by the first parameter). In this instance the query would return all of the records (regardless of day or year) that occured in the month of January.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top