July 17, 2012 at 10:45 am
Hi there -
I can't seem to gather the steam to figure this out today.
I need to find out what the nth weekday of the month is when given a date.
Ex.
today is 7/17/2012
I want to see that it is the 3rd Tuesday of this month (3 Tuesday - something to that effect).
I must be making this out to be harder than it is.
Thanks for any input you have,
matt
July 17, 2012 at 11:03 am
Start with this:
SELECT
ceiling(DAY(GETDATE()) / 7.),
DATENAME(dw, GETDATE()),
ceiling(DAY('20120731') / 7.),
DATENAME(dw, '20120731');
July 17, 2012 at 2:14 pm
Thank you! Perfect, I knew it had to be something simple.:blush:
July 18, 2012 at 12:51 am
Lynn Pettis (7/17/2012)
Start with this:
SELECT
ceiling(DAY(GETDATE()) / 7.),
DATENAME(dw, GETDATE()),
ceiling(DAY('20120731') / 7.),
DATENAME(dw, '20120731');
I LOVE SIMPLE!!!
--Jeff Moden
Change is inevitable... Change for the better is not.
December 14, 2012 at 7:59 am
June 29, 2016 at 3:47 pm
Works like a charm, thanks!
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy