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

sql search strings

Status
Not open for further replies.

ducky62

Programmer
Jul 10, 2001
24
CA
"2/18/02 11:37:56 AM" is what is in my field "replydate" in the database...

in an sql string i want to get all records where replydate >= 2/1/02 and <= 2/28/02

what would the search string be??

thanks
Derek
 
I don't understand the term search string but you've already written the query.

SELECT * FROM yourtable WHERE replydate >= '2/1/02' and replydate <= '2/28/02'

JHall
 
This query will miss all data on 2/28 because it will assume a time of 12:00AM.

SELECT * FROM yourtable
WHERE replydate >= '2/1/02'
AND replydate <= '2/28/02'

Alternatives:

SELECT * FROM yourtable
WHERE replydate >= '2/1/02'
AND replydate <= '2/28/02 23:59:59'

------------------------

SELECT * FROM yourtable
WHERE replydate >= '2/1/02'
AND convert(char(8), replydate, 1) <= '2/28/02' Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top