September 12, 2008 at 3:18 pm
HI,
How to find
a) Second Saturday of the current month,
b) Given date is second Saturday or not.
Please help me.
Regards,
Santosh
September 12, 2008 at 3:25 pm
See http://www.sqlservercentral.com/articles/Advanced+Querying/howmanymoremondaysuntiliretire/2475/
N 56°04'39.16"
E 12°55'05.25"
September 12, 2008 at 3:43 pm
HI,
Thank you for ur quick reply,
I gone through the given link, it gives us the no.of days,
for the given date range,
but
What exactly i want is,
Whether the given date is Second Saturday or not.
Regards,
Santosh
September 12, 2008 at 4:55 pm
Just go from there... don't know how you need to use it, so here it goes :
--Make sure Saturday is the 7th day of the week on your server as well
DECLARE @MyDate AS DATETIME
SET @MyDate = '2008-09-13'
--PRINT DATEPART(dd, @MyDate)
--PRINT DATEPART(dw,@MyDate)
IF (DATEPART(dw,@MyDate) = 7 AND DATEPART(dd, @MyDate) BETWEEN 8 AND 14 )
SELECT 'yup'
ELSE
SELECT 'nope'
September 13, 2008 at 4:21 am
hi,
thank you very much,
this is what exactly i need,
i am calculating the business hours between two days based on shifts using function,
there i need to eliminate the second saturday's as of the requirement
in that function, i am the date is second saturday or not, i need a just line of code to include in that function
" DATEPART(dw,@MyDate) = 7 AND DATEPART(dd, @MyDate) BETWEEN 8 AND 14 "
I am using different logic which is not working fine always,,,,
thank you very much again
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply