Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

count weekend days between two dates sql

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2022/06/01'
SET @EndDate = '2022/06/30'


SELECT
  (DATEDIFF(wk, @StartDate, @EndDate) * 2)
   +(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday'   THEN 1 ELSE 0 END)
   +(CASE WHEN DATENAME(dw, @EndDate)   = 'Saturday' THEN 1 ELSE 0 END)
Source by www.google.com #
 
PREVIOUS NEXT
Tagged: #count #weekend #days #dates #sql
ADD COMMENT
Topic
Name
6+1 =