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 2005 Forums
 Transact-SQL (2005)
 Calculating number of working days between 2 dates

Author  Topic 

ams006
Yak Posting Veteran

55 Posts

Posted - 2010-08-10 : 06:17:43
Hi All,

Does anyone know of a quick way in T-SQL to calculate the number of working days between to datetime fields?

Thanks in Advance

ams006

paulwfromtheden
Starting Member

9 Posts

Posted - 2010-08-10 : 06:19:27
I guess the question is "what is a working day?". The only way that we have solved this is with a table of bank holidays
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-08-10 : 06:20:52
How do you define "working days'?
Do you have a calendar table where you define your days?


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-08-10 : 06:23:03



Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

ams006
Yak Posting Veteran

55 Posts

Posted - 2010-08-10 : 06:36:15
No I don't have a calendar table. I am trying to find the number of days (excluding weekends) between two datetime fields from two different tables.

Do i need to set up a 'calendar table', if so how do i do that? what does it need to hold?

Thanks
Go to Top of Page

ams006
Yak Posting Veteran

55 Posts

Posted - 2010-08-10 : 06:56:59
It's ok guys and girls, not needed anymore as User has just told me they want all days (not just working days)! typical!

Thanks anyway.
Go to Top of Page
   

- Advertisement -