DATETIME2FROMPARTS Date Function TSQL Tutorial

Datetime2fromparts is an date function and returns a datetime2 value for the specified date and time and with the specified precision.

DATETIME2FROMPARTS Syntax:

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

DATETIME2FROMPARTS Example:

SELECT DATETIME2FROMPARTS(2014, 2, 22, 8, 53, 39, 7, 1) as Date_1,
DATETIME2FROMPARTS(2014, 2, 22, 8, 53, 39, 77, 2) as Date_2,
DATETIME2FROMPARTS(2014, 2, 22, 8, 53, 39, 777, 3) as Date_3,
DATETIME2FROMPARTS(2014, 2, 22, 8, 53, 39, 7777, 4) as Date_4;

Date_1Date_2Date_3Date_4
2014-02-22 08:53:39.72014-02-22 08:53:39.772014-02-22 08:53:39.7772014-02-22 08:53:39.7777