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_1 | Date_2 | Date_3 | Date_4 |
---|---|---|---|
2014-02-22 08:53:39.7 | 2014-02-22 08:53:39.77 | 2014-02-22 08:53:39.777 | 2014-02-22 08:53:39.7777 |