I'm using Microsoft sql server and in the sql server by default first day of week is Sunday but I need to set it Monday is the first day of week.
Asked
Active
Viewed 337 times
3
-
1https://database.guide/set-datefirst-set-the-first-day-of-the-week-in-sql-server/ – Ajan Balakumaran Apr 09 '19 at 07:44
-
2Ideally (to my mind) you write `DATEFIRST` agnostic code instead - find ways using e.g. "known good" dates to avoid depending on *particular* values returned by e.g. `DATEPART`. – Damien_The_Unbeliever Apr 09 '19 at 07:49
4 Answers
4
This sets the first day of the week to Monday
SET DATEFIRST 1;

Nipun Tharuksha
- 2,496
- 4
- 17
- 40

Shadiqur
- 490
- 1
- 5
- 18
3
You can use
SET DATEFIRST { number }
number
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
7 Sunday
Here the link to the official docs: https://learn.microsoft.com/en-US/sql/t-sql/statements/set-datefirst-transact-sql?view=sql-server-2017

Pierre
- 794
- 5
- 15