set DATEFIRST (Transact-sql)

Haftanın ilk günü, 1 ile 7 arasında bir sayıya ayarlar.

Tüm genel bakış için Transact-SQLbkz: Tarih ve Saat veri türleri ve işlevler, Tarih ve Saat veri türleri ve işlevler (Transact-sql).

Konu bağlantısı simgesi Transact-SQL Sözdizim Kuralları

Sözdizimi

SET DATEFIRST { number | @number_var } 

Bağımsız değişkenler

  • number | **@**number_var
    Haftanın ilk gününü belirten bir tamsayıdır. Aşağıdaki değerlerden biri olabilir.

    Değer

    Haftanın ilk günü

    1

    Pazartesi

    2

    Salı

    3

    Çarşamba

    4

    Perşembe

    5

    Cuma

    6

    Cumartesi

    7 (varsayılan, u.s. Turkish)

    Pazar

Açıklamalar

set DATEFIRST geçerli ayarları görmek için @@ DATEFIRST işlevi.

set DATEFIRST ayarı ayarlanır yürütme veya zaman değil ayrıştırma saati ve çalıştırın.

İzinler

Üyelik Genel rolü.

Örnekler

Aşağıdaki örnek Tarih için haftanın gününü görüntüler ve değiştirmenin etkileri DATEFIRSTayarı.

-- SET DATEFIRST to U.S. English default value of 7.
SET DATEFIRST 7;

SELECT CAST('1999-1-1' AS datetime2) AS SelectDate
    ,DATEPART(dw, '1999-1-1') AS DayOfWeek;
-- January 1, 1999 is a Friday. Because the U.S. English default 
-- specifies Sunday as the first day of the week, DATEPART of 1999-1-1
-- (Friday) yields a value of 6, because Friday is the sixth day of the 
-- week when you start with Sunday as day 1.

SET DATEFIRST 3;
-- Because Wednesday is now considered the first day of the week,
-- DATEPART now shows that 1999-1-1 (a Friday) is the third day of the 
-- week. The following DATEPART function should return a value of 3.
SELECT CAST('1999-1-1' AS datetime2) AS SelectDate
    ,DATEPART(dw, '1999-1-1') AS DayOfWeek;
GO

-- SET DATEFIRST to U.S. English default value of 7.
SET DATEFIRST 7;

SELECT CAST('1999-1-1' AS datetime2) AS SelectDate
    ,DATEPART(dw, '1999-1-1') AS DayOfWeek;
-- January 1, 1999 is a Friday. Because the U.S. English default 
-- specifies Sunday as the first day of the week, DATEPART of 1999-1-1
-- (Friday) yields a value of 6, because Friday is the sixth day of the 
-- week when you start with Sunday as day 1.

SET DATEFIRST 3;
-- Because Wednesday is now considered the first day of the week,
-- DATEPART now shows that 1999-1-1 (a Friday) is the third day of the 
-- week. The following DATEPART function should return a value of 3.
SELECT CAST('1999-1-1' AS datetime2) AS SelectDate
    ,DATEPART(dw, '1999-1-1') AS DayOfWeek;
GO

Ayrıca bkz.

Başvuru

Deyimiyle (Transact-sql) bırak