Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query on time only when we have date time.

Author  Topic 

shukla_dh
Starting Member

9 Posts

Posted - 2010-06-17 : 05:40:45
I have one table Employee which store employee birthdate which contains birth date and time both.

Select * from Employee 


Result should like

ID Name BirthDate



1 ABCD 2000-01-01 19:00:00.000
2 XYA 2000-01-01 05:15:00.000

Now i want to make query on employee table where birthtime is either more then 02:00 and less then 15:00 or any kind of comparison operator.

Do you have any idea.



Dhaval Shukla
.Net Developer

SD_Monkey
Starting Member

38 Posts

Posted - 2010-06-17 : 06:22:40
@cond1 datetime
@cond2 datetime

where birthtime between @cond1 AND cond2

hope this can help....


A maze make you much more better
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-17 : 06:24:01
select * from employee where datepart(hh, birthdate) between 2 and 15

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -