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.
| Author |
Topic |
|
sampcuk
Starting Member
32 Posts |
Posted - 2009-03-04 : 09:49:04
|
| Hi,I need to count how many employees we had employed on a certain date using SQL. My aim is to work out labour turnover by using leavers for a certain period divided by the current staff x 100.How do I get the employees on a certain date though? I have been at it for ages on this!ThanksS |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-04 : 09:52:43
|
| select count(*) from employeeswhere date_col>=dateadd(day,datediff(day,0,@date),0)and date_col<dateadd(day,datediff(day,0,@date),1)MadhivananFailing to plan is Planning to fail |
 |
|
|
sampcuk
Starting Member
32 Posts |
Posted - 2009-03-04 : 10:20:14
|
| Sorry but this is a sill question, where do I put the desired date in? I am getting an error message about a scalar variable?! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-04 : 10:22:18
|
quote: Originally posted by sampcuk Sorry but this is a sill question, where do I put the desired date in? I am getting an error message about a scalar variable?!
@date ia place where you put your date value inDECLARE @Date datetimeSET @date= your date value hereselect count(*) from employeeswhere date_col>=dateadd(day,datediff(day,0,@date),0)and date_col<dateadd(day,datediff(day,0,@date),1) |
 |
|
|
|
|
|
|
|