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
 Development Tools
 Reporting Services Development
 how to calculate hours between 2 dates excluding w

Author  Topic 

agenda9533
Starting Member

16 Posts

Posted - 2005-11-09 : 16:10:02
Looking for way&logic to calculate hours between 2 dates (Ticket.date_opened and Ticket.solved_date) but excluding weekends ?
This function calculates hours only
DATEDIFF(hour, Ticket.date_opened, Ticket.solved_date).

Thanks!

catzarecute
Starting Member

1 Post

Posted - 2005-12-20 : 17:22:41
(DateDiff(Hour, Ticket.date_opened, Ticket.solved_date) - ((DateDiff(Week, Ticket.date_opened, Ticket.solved_date) * 2) * 24))

The first being the raw hours, then subtracted from the week boundary, multiplied by 24 (hours). This gives Total Hours, NOT including weekends.

Does this help ?

=^..^=
Go to Top of Page
   

- Advertisement -