I need some help creating a function that will return a string formated like hh:mm:ss. The function will have two parameters and is set up as follows...
Create Function ftnGetElapsedTime(@x_StartDate DATETIME, @x_EndDate DATETIME)
Returns CHAR(08)
The business logic excludes "Off" hours in the calculation. "Off" hours are between "03:00:00" and "10:00:00" daily.
So for example,
StartTime EndTime Return
2005-01-01 01:00:00 2005-01-01 12:00:00 05:00:00
2005-01-01 03:30:00 2005-01-01 09:30:00 00:00:00
2005-01-01 02:30:00 2005-01-02 01:00:00 15:30:00
2005-01-01 12:00:00 2005-01-01 12:15:00 00:15:00
The purpose of the function is to calculate the working time difference between the Start and End dates excluding the "Off" hours.
Create Function ftnGetElapsedTime(@x_StartDate DATETIME, @x_EndDate DATETIME)
Returns CHAR(08)
The business logic excludes "Off" hours in the calculation. "Off" hours are between "03:00:00" and "10:00:00" daily.
So for example,
StartTime EndTime Return
2005-01-01 01:00:00 2005-01-01 12:00:00 05:00:00
2005-01-01 03:30:00 2005-01-01 09:30:00 00:00:00
2005-01-01 02:30:00 2005-01-02 01:00:00 15:30:00
2005-01-01 12:00:00 2005-01-01 12:15:00 00:15:00
The purpose of the function is to calculate the working time difference between the Start and End dates excluding the "Off" hours.