Get first and last day of week in sql

There are many ways to achieve the same kind of functionality in sql server. When I was designing a database for my new project i was wondering to know regarding some functionality and suddenly i got a very simple solution to get first and last day of week in sql. So with a just single line of query we can get our result.

Below query will give the first day of week. If somebody want to get the first day of the week from some other date, just replace the GETDATE() with your date column or date variable.

SELECT "START_OF_WEEK" = DATEADD(WEEK, DATEDIFF(WEEK,0, GETDATE()),0);

To get the last day of the week use below query. Same as above replace the GETDATE() with your column or date variable.

SELECT "END_OF_WEEK" = DATEADD(WEEK, DATEDIFF(WEEK,0, GETDATE()),6);

Here I have explained get first and last day of week in sql. Please be updated with Technothirsty.com

Leave a Reply