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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 select records from a table based on Datetime.

Author  Topic 

sheenawee
Starting Member

2 Posts

Posted - 2006-06-06 : 22:48:32
Hi, im a newbie here... started to learn sql not long ago. Am currently trying to query a range of datetime.

My current problem is, I have a set of table that contains employee's leave information. The requirement is , i need to display all the employee's leave information from current date until next 14 days. How do i write this query?

Please help....Thank you very much!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-06 : 23:23:00
[code]
select *
from employee_leave_information
where leave_date >= dateadd(day, datediff(day, 0, getdate()), 0)
and leave_date < dateadd(day, datediff(day, 0, getdate()) + 15, 0)
[/code]


KH

Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2006-06-06 : 23:30:08
Find out what they are really wanting. Is it 14 business days??? Is it 14 day period? What about holidays? You might need a calendar table. Righting SQL is easy. Finding out real requirements can be a pain.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

sheenawee
Starting Member

2 Posts

Posted - 2006-06-07 : 02:21:28
Thank you for your advise there. I had not thought about that requirement yet. Will b checking out with my system analyst here.

Derrick n KH, thank you very much
Go to Top of Page
   

- Advertisement -