Partilhar via


@@DATEFIRST (Transact-SQL)

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

Topic link iconTransact-SQL Syntax Conventions

Syntax

@@DATEFIRST

Return Types

tinyint

Remarks

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

Language settings affect date information. In the following example, the language is first set to italian. SELECT @@DATEFIRST returns 1. The language is then set to us_english. SELECT @@DATEFIRST returns 7.

SET LANGUAGE italian
GO
SELECT @@DATEFIRST
GO
SET LANGUAGE us_english
GO
SELECT @@DATEFIRST

Examples

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 '1st Day', DATEPART(dw, GETDATE()) AS 'Today'

Here is the result set:

1st Day           Today
----------------  --------------
5                 2

See Also

Reference

DATEPART (Transact-SQL)
Configuration Functions (Transact-SQL)
SET DATEFIRST (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

14 April 2006

New content:
  • Added information about the effect of language settings on @@DATEFIRST.