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!

One month records only Sql Server 2005 1

Status
Not open for further replies.

macsql1

Programmer
Jan 20, 2008
25
IN
Hi,

I want records for only one month, between 1st January 2007 till 31st January 2007.

I written following query, but output also gives for January 2008 and 2009 using sql server 2005. Kindly help..

select convert(varchar,LastDate,101), * from Table1 where
(convert(varchar,LastDate,101) >= '01/01/2007' and convert(varchar,LastDate,101) <= '01/31/2007')

-Mac

 
Don't convert to and compare char data, use
Code:
where LastDate>='20070101'
  and LastDate<'20070201'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top