CREATE FUNCTION fn_isbusinessday (@date DATETIME)RETURNS INT
AS
BEGIN
DECLARE @return int
DECLARE @CurMonth int
SET @Return = 0
SET @CurMonth = DATEPART(mm,@Date)
SET @Date =DATEADD(DD,-1,@Date)
WHILE DATEPART(mm,@Date) = @curMonth
BEGIN
IF DATENAME(WEEKDAY, @DATE)NOT IN ('saturday', 'sunday')
SELECT @return = @return +1
SET @Date =DATEADD(DD,-1,@Date)
END
RETURN @return
END
GOSELECT dbo.fn_isbusinessday(GETDATE())
Label List
- Architecture
- Art of SQL Server
- asynchronous mirroring
- csv
- dmv
- find outdated Statistics
- Free SQL Server tools
- index fragmentation
- Installation
- Katmai
- Learn SQL Server 2005
- Maintenance Plan
- outdated Statistics
- Reset Identity column
- Scripts
- SPID
- sql server 2008
- sys.dm_db_index_physical_stats
- sys.dm_exec_connections
- tsql
- update statistics