I'm creating an ASP.NET application (C#), I'm nearly finished however I have the following question.
Scenario
In my MSSQL table I have a datetime value i.e. 2015-05-06 13:38:17.000 I need to find out if this is over 6 hours old but I need to take into account the fact we are only working from 8:30-18:00 Monday to Friday.
I currently work out if an item is over 4 hours old (not taking working hours into account) using the following query:
SELECT COUNT(*) FROM Table WHERE [DateSubmitted] < DATEADD(HOUR,-4,GETDATE())
I've read up on how to calculate the working hours: Calculate business hours between two dates but I don't know how to apply this to what I want to do.
Any help would be appreciated - thank you.