Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,


i have a table which contains startdate and enddate column.

ex startdate enddate
2011-07-13 00:00:00.000 2011-07-14 00:00:00.000


i want to perform a search on the basis of startdate
the issue is that if i enter strat date as 2011-07-13 00:00:01.000


the above record should be displayed.
Posted

@givenTime = '2011-07-13 00:00:01.000'

select * from [table] where startdate < @givenTime and enddate > @givenTime
 
Share this answer
 
v2
Try something from here[^] - it may help.
 
Share this answer
 
Not that difficult

SELECT *
FROM table
WHERE @date >= startdate AND @date <= enddate
 
Share this answer
 
Or, convert the datetime into a date:
SQL
SELECT * FROM yourTable WHERE (CONVERT([date], @date) = CONVERT([date], startdate))
 
Share this answer
 
select
SQL
* from Attendance_Master where datename(d,LoginTime)=datename(d,@date)
                             and datename(m,LoginTime)=datename(m,@date)and  datename(year,LoginTime)=datename(year,@date)
 
Share this answer
 
Hi ,

it picks all the records based on the condition

select * from table where date between startdate and enddate.
 
Share this answer
 
Comments
shefeekcm 21-Jul-11 7:39am    
ust try this man.
Write the following code to get your work done ..... make sure that you enter the date in single quotation then only it will work properly .... or else it will not work as you expect it to work .... but at the same time it will not throw you any error also .....


so please make sure that you use the quotation while entering the date

SQL
SELECT *
FROM table
WHERE @date >= startdate AND @date <= enddate
 
Share this answer
 
select * from table where date in ('start date','end date')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900