Skip to content Skip to sidebar Skip to footer

How To Search Date In Sql?

I am having an Event Management System in which i want, If an event is registered for 5 days (21 jan 2009 to 26 Jan 2009) Then if another person wants to register an event between

Solution 1:

Just a to complete other answers, you have a good article on How to Search for Date and Time Values Using SQL Server 2000

It reminds you about how date/time values are stored (two date/time data types: datetime and smalldatetime)

It also points out Datetime and smalldatetime are like the floating-point data types, float and real, in that they’re approximate numerics. That means the value retrieved from SQL Server may be different from the value that was originally stored.

Plus, it warns about Database designers who don’t always use date/time columns appropriately. At the time the database is designed, each date/time column should be identified as to whether it will store both dates and times, dates only, or times only.

It closes with practical queries on data/time.

You also have a good description of DATEADD and DATEDIFF here.

Solution 2:

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)

Solution 3:

Lookup DATEDIFF in SQL help.

Post a Comment for "How To Search Date In Sql?"