question

Kshivamu avatar image
Kshivamu asked

get the data between previous month second friday till current date using SQL.

Hi I need the data between previous month second friday till current date using SQL.

sql-server-2012
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·

What have you tried so far?

0 Likes 0 ·

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered

This appears to generate the second Friday of the previous month. Over to you to leverage that in your query.

SELECT        DATEADD(
                  DAY,
                  13 - DATEPART(WEEKDAY, DATEADD(DAY, 0, DATEADD(MONTH, DATEDIFF(MONTH, '20010101', @getdate) - 1, '20010101'))),
                  DATEADD(MONTH, DATEDIFF(MONTH, '20010101', @getdate) - 1, '20010101')
              ) AS SecondFridayOfLastMonth
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.