SQL DATETIMEOFFSETFROMPARTS Function

DATETIMEOFFSETFROMPARTS creates a datetime value with an offset.

The returned value is based on the specified date and time part arguments.

All arguments are required. If any is null, null is returned.

Example

#

This example returns a datetimeoffset value from the specified dateparts.

SELECT DATETIMEOFFSETFROMPARTS(2022, 5, 28, 11, 54, 17, 0, 12, 0, 7) 
    AS DatetimeOffset
Result:  1 record
Datetime
2022-05-28 11:54:17 AM +12:00

Syntax

Syntax of the DATETIMEOFFSETFROMPARTS function .

DATETIMEOFFSETFROMPARTS(year, month, day, 
                  hour, minute, seconds, fractions,
                  hour_offset, minute_offset, precision) 

year -- an integer specifying year.

month -- an integer specifying month.

day -- an integer specifying day of month.

hour -- an integer specifying the hour.

minute -- an integer specifying the minute.

seconds -- an integer specifying the seconds.

fractions -- an integer specifying the fractional seconds value.

hour_offset -- an integer specifying the timezone offset hour portion.

minute_offset -- an integer specifying the timezone offset minute portion.

precision -- the precision of the return DATETIMEOFFSET value.

Note: DATETIMEOFFSETFROMPARTS will return an error if any of the arguments is invalid. If any of the arguments is null, then the return value will also be null.


You may also like



Guides


vsn 3.1