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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal VaishyaRank #990 · 2K reputationPosted Apr 25, 2012, 6:20 PM EDT
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 25, 2012, 6:27 PM EDT
Please refer the below link
http://www.securitypronews.com/it/database/spn-20-20031023HowtoSearchforDateandTimeValuesUsingMicrosoftSQLServer2000.html
Thanks
SenthilkumarRank #387 · 6.5K reputationPosted Apr 25, 2012, 7:28 PM EDT
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/
MuthuMari MRank #5,738 · 288 reputationPosted Apr 25, 2012, 8:59 PM EDT
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"