Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Business Time in Seconds Function

By provost,

SQL Function to calculate number of business seconds between 2 datetime fields.
Input Parameters:
@startdate - Start Time (datatype DateTime)
@enddate - End Time (datatype DateTime)
@starthour - Start of Business Day (datatype DateTime) (Format: '1900-01-01 9:00:00')
@endhour - End of Business Day (datatype DateTime) (Format: '1900-01-01 17:00:00')
@workdays - Business Day string - Use Dash ('-') for Non-Business Day (datatype char(7)) (Format: '-MTWTF-')

Note: Function does not exclude holidays.

Total article views: 212 | Views in the last 30 days: 1
 
Related Articles
FORUM

datetime format

datetime format as yyyy-mm-dd

FORUM

Converting string to datetime format

Converting string to datetime format

FORUM

Formating DateTime

Formating a DateTime Column to be just date

FORUM

DateTime Problem

Datetime

FORUM

Need DateTime format and count of records

Need DateTime format and count of records

 
Contribute