I want to know how to perform date search in SQL Server.
Thank you.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MuthuMari MPosted Apr 26, 2012, 12:59 AM
you can search like this.
1.
SELECT *
FROM events e
WHERE (@startDate BETWEEN e.startDate and e.endDate)
OR (@endDate BETWEEN e.startDate and e.endDate)
OR (@startDate < e.startDate AND @endDate > e.endDate)
2. SELECT * FROM vtest WHERE resultdate = "2010-10-08";
3. SELECT * FROM DateSample
WHERE DateVal BETWEEN '2002-02-28' AND '2002-02-28 23:59:59.997'
4.
SELECT DATEDIFF(YEAR,'2011-12-31 23:59:59' , '2012-01-01 00:00:00') AS YEAR_DIFFthanks.
If this post is useful then mark it as "Accepted Answer"
SenthilkumarPosted Apr 25, 2012, 11:28 PM
Please refer these articles.
http://www.securitypronews.com/it/database/spn-20-20031023HowtoSearchforDateandTimeValuesUsingMicrosoftSQLServer2000.html
http://www.devarticles.com/c/a/SQL-Server/Date-and-Time-Values-Using-SQL-Server-2000/
Satyapriya NayakPosted Apr 25, 2012, 10:27 PM
Please refer the below link
http://www.securitypronews.com/it/database/spn-20-20031023HowtoSearchforDateandTimeValuesUsingMicrosoftSQLServer2000.html
Thanks
Kunal VaishyaPosted Apr 25, 2012, 10:20 PM