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!

Need to Select Year Only

Status
Not open for further replies.

heathL

MIS
Jan 30, 2003
10
US
I want to write a select statement to find dates with 2002 only. If I use the entire date format for a single date like 1/1/2002 (see the code below), it works but I want to find all 2002 dates not just one.


sql = "SELECT * FROM tblNewsStories Where archived='Yes' AND Date = '1/1/2002' ORDER BY date DESC"
 
sql = "SELECT * FROM tblNewsStories Where archived='Yes' AND Date > '12/31/2001' ORDER BY date DESC"

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
sql = &quot;SELECT * FROM tblNewsStories Where archived='Yes' AND Date > '31/12/2001' AND Date < '1/1/2003' ORDER BY date DESC&quot;
 
Good catch chmohan... I missed the 2000 only part of the question.

Craig

&quot;I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day.&quot;
~Frank Sinatra
 
sql = &quot;SELECT * FROM tblNewsStories Where archived='Yes' AND DATEPART(yyyy, Date) = '2002' ORDER BY date DESC&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top