Site icon Database Tutorials

SET DATEFIRST Statement and @@DATEFIRST Function in SQL Server(TSQL)

 

We can set the first day of the week for a session with SET DATEFIRST Statement. We can query the first day of the week for a session with the @@DATEFIRST Function.

First, by opening a session, let’s query the first day of the week with the @@DATEFIRST function.

For a more meaningful result instead of 7, let’s change the query as follows.

Now let’s set the first day of the week to 1 and run the same query.

Exit mobile version