Export (0) Print
Expand All
Expand Minimize

@@DATEFIRST (Transact-SQL)

Returns the current value, for a session, of SET DATEFIRST.

For an overview of all Transact-SQL date and time data types and functions, see Date and Time Data Types and Functions (Transact-SQL). For information and examples that are common to date and time data types and functions, see Using Date and Time Data.

Topic link iconTransact-SQL Syntax Conventions


@@DATEFIRST

SET DATEFIRST specifies the first day of the week. The U.S. English default is 7, Sunday.

This language setting affects the interpretation of character strings as they are converted to date values for storage in the database, and the display of date values that are stored in the database. This setting does not affect the storage format of date data. In the following example, the language is first set to Italian. The statement SELECT @@DATEFIRST; returns 1. The language is then set to us_english. The statement SELECT @@DATEFIRST; returns 7.

SET LANGUAGE Italian;
GO
SELECT @@DATEFIRST;
GO
SET LANGUAGE us_english;
GO
SELECT @@DATEFIRST;

The following example sets the first day of the week to 5 (Friday), and assumes the current day, Today, to be Saturday. The SELECT statement returns the DATEFIRST value and the number of the current day of the week.

SET DATEFIRST 5;
SELECT @@DATEFIRST AS 'First Day'
    ,DATEPART(dw, SYSDATETIME()) AS 'Today';

Here is the result set.

First Day         Today
----------------  --------------
5                 2
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft