Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 206 | Views in the last 30 days: 1
 
Related Articles
FORUM

datetime format

datetime format as yyyy-mm-dd

FORUM

Formating DateTime

Formating a DateTime Column to be just date

FORUM

Converting string to datetime format

Converting string to datetime format

FORUM

DateTime Problem

Datetime

FORUM

Convertion of integer to Datetime format

Convertion of integer to Datetime format

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones