Dofactory.com
Dofactory.com
Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

SQL DATETIMEFROMPARTS Function

DATETIMEFROMPARTS creates a datetime value.

The returned value is based on the specified datepart arguments.

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

Example

#

This example returns a datetime value from the specified dateparts.

SELECT DATETIMEFROMPARTS(2022, 5, 28, 11, 54, 17, 0) 
    AS Datetime
Result:  1 record
Datetime
2022-05-28 11:54:17.000

Syntax

Syntax of the DATETIMEFROMPARTS function .

DATETIMEFROMPARTS(year, month, day, 
                  hour, minute, seconds, milliseconds) 

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.

milliseconds -- an integer specifying the milliseconds.

Note: DATETIMEFROMPARTS 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



Last updated on Dec 21, 2023

Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.