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

Searching by different date formats

Status
Not open for further replies.

fletch518

Technical User
Oct 2, 2001
5
US
Is there a simple way to do a search by using a mm/yy format to find data in a mm/dd/yyyy format. I tried using a query that would add days to the mm/yy format (since I'm assuming Access believes the data to be from the first day of the month), but no luck. I'm probably missing a VERY obvious solution here, so feel free to kick me if that's the case.
 
Add a field to your query with this in your "Field:" box:
Code:
 Format([Your_Date],"mm/yy")
Enter your criteria in mm/yy format.......
 
I'm not sure if that will help in the short term. I'm using a mm/yy date on a form as the criteria for the query to find the appropriate records. However, you're response did help me find a temporary solution. Maybe I should rephrase now that it's working (within the last 10 mins).

Is there perhaps a way to specify a selection to be the last day in the month in a query (I'm horrendous w/ VB)? So far, I've done things the roundabout way and converted the date type in my query to modify the MM/YY value on the form to a mm/dd/yy and then search my table for it. So to get the whole month, I'm using an expression that adds the first day of the month plus 30. Obviously, this doesn't work on short months, as other records at the beginning of the month will be gathered as well.

Thx,
Fletch
 
Maybe I'm missing something.

Say you have a date field in your database called Your_Date whose format is mm/dd/yy. Add a field to your query:
Code:
Fmt_date: Format([Your_Date],"mm/yy")
Either hard-code a date or use a parameter to enter a date in mm/yy format as the criteria for Fmt_date. The query will return all records for that mm/yy
 
Doh! Thanks for sticking with me. I had a brainfart there due to a lack of sleep. Thanks for your time and patience, works like a charm. All's well in Metropolis, once again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top