How to find Last Friday of each Month of an year in SQL Server

0
2514

Question :-  How can we find first Friday and last Friday of each month in SQL Server?

Description :-  This is one of the important question from SQL Server category, if you are preparing for any interview. Moreover, it is also used in majority of the IT projects. One scenario where it can be required to find the last Friday of each month is- To calculate Pay days for the employees (As, Paydays occur on the last Friday of each month). There can be numerous methods to tackle this question. But, I will be showing one very simple method to find last Friday of each month in SQL Server.

NOTE  This method can also be used to find any first or last day of a month in SQL Server (say last Sunday or last Tuesday, etc). It is very simple, you just have to customize it as per your business logic.

First and Last Friday of each Month

Answer :-  Let’s calculate the first Friday and last Friday for the year 2016 in SQL Server with the following query.

Below is the screenshot attached in which you can see First Friday, Last Friday and Number of Weeks in each month.

Calculate First Friday and Last Friday of each Month of an Year in SQL Server
Calculate First Friday and Last Friday of each Month of an Year in SQL Server

With this we reached an end to our post on “How to calculate first Friday and last Friday of each Month of an Year in SQL Server“. There are numerous ways to find the last Friday of each month. I will really appreciate those people who can add more methods as answers to this question as comments below. I hope you must have enjoyed this article and kindly write to us if you have any queries or feedback.

VN:F [1.9.22_1171]
Your Feedback hels to Improve
Rating: 9.9/10 (14 votes cast)
VN:F [1.9.22_1171]
Rating: +15 (from 15 votes)
How to find Last Friday of each Month of an year in SQL Server, 9.9 out of 10 based on 14 ratings