SQL Flow Field Guide

DATEPART

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

date/time arithmetic, parts, construction or truncation

What changes

Input
date/time arguments
Output or change
date/time or integer value
Return type
int

Syntax at a glance

DATEPART ( datepart , date )

Work example

Read a numeric date part for a label or grouped analysis.

Include year with month or week and prefer a half-open range for indexed date filtering.

Check your work DATEPART results for week-related parts can depend on DATEFIRST and language settings.

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