SQL Flow Field Guide

DATETIME2FROMPARTS

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
datetime2( precision )

Syntax at a glance

DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision )

Work example

Build a datetime2 value from calendar and fractional-second parts.

Test month end, leap day, offset, and the session language that will run the query.

Check your work Choose precision and test invalid dates and fractional values at the declared scale.

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