|
|
|
This T-SQL script shows how to calculate the number of days between a given date and the 3rd sunday of the current month. This can be easily modified to accomodate count till 3rd saturday or 3rd monday of current month & so on. |
Click here to copy the following block | DECLARE @StartDate datetime , @EndDate datetime SELECT @StartDate = '2/13/2000' , @EndDate = CAST( CAST( YEAR( GETDATE() ) AS varchar ) + RIGHT( '00' + CAST( MONTH( GETDATE() ) AS varchar ) , 2 ) + '01' as datetime )
SELECT DATEDIFF( dd , @StartDate , DATEADD( dd , 14 + ( 7 - DATEPART( dw, @EndDate ) ) , @EndDate ) ) AS #Days |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|