special date/time comparisons
Greetings,
I hope everyone is doing well.
I have a table setup with multiple date/time columns that I need to run date comparisons on. Initially, I was just using a simple Date1 - Date2 calculation to get the difference in days. However, my requirements have recently changed such that I must calculate elapsed business hours rather than just the plain elapsed time.
For example, let's say Monday's and Tuesday's business hours are 7am - 7pm. If an order is placed at 4pm on Monday and delivered at 8am on Tuesday, the regular elapsed time would be 16 hours. The elapsed time in business hours would be 4 hours.
Therefore, I would need an algorithm that could calculate elapsed business hours if given a schedule of business hours.
Before I go off to try to put this together, I was wondering if anyone had tackled a similar task and had some sample code to offer.
Thanks for the help.
|