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

Date problem

Status
Not open for further replies.

raybetts

Programmer
Joined
Apr 27, 2000
Messages
6
Location
CH
I have a table with an ID, a qty, and a date (datetime) in sql 7.&nbsp;&nbsp;I want to query the database and retrieve all recs grouped by a given month. So rather than saying give me all recs = xx/xx/xxxx, I want to say give me all recs = 10 (or oct).&nbsp;&nbsp;Is this possible and if so how.<br><br>Cheers,<br><br>Ray.
 
Try this:<br><br><FONT FACE=monospace>select ID, qty, date<br>from MyTable<br>where DatePart(month,Date)=10</font><br><br>You probably want to go by month and year, so you may want to try:<br><br><FONT FACE=monospace>select ID, qty, date<br>from MyTable<br>where DatePart(month,Date)=10 and DatePart(year,Date)=1999</font><br><br>Let me know if this works.....
 
Thanks Darkman it works like a dream.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top