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

Can you pattern match for date fields? 2

Status
Not open for further replies.

robertsfd

Technical User
Apr 18, 2003
40
I have a table with a date field. I want to restrict query results to dates of a certain month. I'm thinking this could be done with LIKE something such as the follows (example assumes I want dates of March):

WHERE Date LIKE 3*

Is this possible? I can't figure out how to do something like this where the data type is a date? The best I could do is this:

WHERE Left(Date,1)=3

But this only works on months 2 through 9. Put a 1 in and you get January, October, November, and December. I tried Left(Date,2)=3 but this doesn't work at all.

Any suggestions? I've tried everything I could think of with various combinations of wildcard characters. I think you may only be able to do this on string/text data.
 
WHERE Month([your Date field])=3

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
something like this should work:

WHERE Month(DateField) = 3

(ps you shouldn't have a field named "DATE", reserved word!)

leslie
 
Wonderful. Thanks to you both. It works as intended.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top