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 |
|
kbearhome
Starting Member
36 Posts |
Posted - 2004-10-26 : 17:55:41
|
| Does SQL have a function to calculate date diff with just work days like Excel has networkdays?Thanks |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2004-10-26 : 18:31:07
|
No,To do this you can use a tally table (table with just numbers).or you could keep a calender table where the workdays/holidays etc are marked as such.Join on the tally table and count only the workdays,something along the lines of:select count(*) as workdaysfrom myTable join tallyon tally.nr between cast(myTable.dateFrom as int) and cast(myTable.dateTo as int)where datepart(dw,cast(tally.nr as datetime)) between 2 and 6 -- assuming days 2-6 are workdays of course to take into account the actual holidays a calender table would be necessary.rockmoose/* Chaos is the nature of things...Order is a lesser state of chaos */ |
 |
|
|
kbearhome
Starting Member
36 Posts |
Posted - 2004-10-27 : 13:19:43
|
| Thank you |
 |
|
|
|
|
|