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

Selecting Where Month is in date

Status
Not open for further replies.

colzboppo

Programmer
Sep 20, 2001
9
GB
I need (in my SQL) to select records from my Access DB where a paticular Month matches the one in the Date field.
So I pull out all records for one paticular month.

I tryed:(September select example)
"SELECT * FROM tblStats ORDER BY Date WHERE Date=#10/%/%#"
But this doesn't work. Doh!
Got any ideas anyone?

Thanks guyz
 
Hi,

Try:
SELECT [tblStats].*, Month([dateField]) AS expr1
FROM [tblStats]
WHERE (((Month([dateField]))=1));

Also, I don't recommend naming fields the same as reserved words. Eg. Date is a reserved word in Access Hope this is ok. If not, just let me know.

Nick (Everton Rool OK!)
 
fanks Mate, too late though, I created a between in the where clause instead, using some Tasty VBscript to get the first and last days of that particular month.
I always solve my problems by looking at them from a different angle!
Oh and the design of TblStats, that was given to me in an article by ASP101, I didn't realise but that is heavy puttin a rezzed word as a field, i know now, cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top