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

Query to check date for a specific month

Status
Not open for further replies.
Jul 14, 2003
116
CA
How can write a SQL query that checks a data string for a specific month? I need to count the number of records that take place within a certain month regardless of what day of the month it is. Any suggestions?
 
alexkeel79,

If the field is a Date Type then, FYI, your Date is REALLY a number. You must CONVERT to a string...
[tt]
Where Format(MyDate, "mmm")='Jan'
[/tt]


Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Hi

In the query grid

MyMonth:Month(MyDate)

Criteria 10

to pick out all in October regardless of day or year

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I need to count the number of records that take place within a certain month
SELECT Format([date field name], "yyyy-mm") As [Month], Count(*) As CountOf
FROM [table name]
GROUP BY Format([date field name], "yyyy-mm");

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top