|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Best way to search for values in a range of dates
I know there are a millions ways to do this. I think I am doing this the most inefficiennt way.
What is the best T-SQL Script to return a set of values within a range of dates. The lower and upper dates are provided by the user. For example the input to the T-SQL stored proc would be 2 dates (i.e. 10/16/2004 and 2/18/2005) chosen by the user. The script will return all entries that were created on those dates (assuming the table in SQL server has a timedate stamp that was filled automtically when each row in the table was populated) i.e. tbl_sample has columns ----------------------------------- name description time-date stamp ----------------------------------- Thanks, Any help would be good. |
|
#2
|
||||
|
||||
|
Code:
declare @startdate datetime declare @enddate datetime select * from tablename where timefield between @startdate and @enddate That should do the trick... |
|
#3
|
|||
|
|||
|
Thanks. That's the way I am using right now
and its proably good enough! |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Best way to search for values in a range of dates |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|