Hello -
I've been tearing my hair out over this problem i'm trying to solve, probably just been staring at it too long which is making it worse -
I have a series of open support tickets which are supposed to be updated on a daily basis, the problem is that they aren't always being updated daily. So, the business wants to know the number of days from when a ticket was last updated and today's date. I have this basic calculation and it's working fine, however now the business wants to exclude weekends from the calculation. The other problem is that some reps DO go in on weekends and update their tickets, so sometimes there will be updates made on weekend dates.
To give an example -
Today's date is 2014-02-10 (Monday). A ticket was last updated last Thursday, 2014-01-30. The difference between the two dates is 11, so it's been 11 days since the ticket was last updated. Now, if I exclude Saturdays and Sundays, then it's actually been 7 days since the ticket was last updated. I'm not sure how to do this in T-SQL.
Now, to further complicate the problem, sometimes a ticket IS updated on a Saturday or Sunday. So, if a ticket was updated on 2014-02-02 (Sunday), then it should be counted. Again i'm not sure how to do this.
What gets me is that this is probably fairly simple and i've just been staring at it too long. In the meantime, can someone offer some guidance?
Thanks!!