SQL Flow Field Guide

SET DATEFIRST

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

first day of week; changes DATEPART(weekday) and @@DATEFIRST

What changes

Input
none
Output or change
session state

Syntax at a glance

SET DATEFIRST { number | @number_var }

Work example

A date or time calculation must use the explicit calendar behavior controlled by SET DATEFIRST.

Test month, week, daylight-saving, and boundary values. Prefer typed date or time-zone conversion over parsing an ambiguous string.

Check your work SET DATEFIRST. The boundary results for SET DATEFIRST match the named locale or time-zone rule and do not depend on a login default.

Open Microsoft Learn for full syntax, permissions, and details for your version.