Combines separate date and a time values into a DateTime value.
The function supports two different types of data syntax; either a separate
date and optional
time value or a single
string containing a valid date and optional time.
See the
Date / Time Functions section for detailed information concerning date / time formats.
Syntax 1: A Date and optional Time datatypes. This syntax expects a date datatype and an optional time datatype. If the optional time datatype is specified, the values MUST be seperated with a comma.
Syntax 2: A string containing a valid date and optionally a valid time. The date and time formats supported are the same as those in the date() and time() functions respectively. You can separate the date and time values by either a comma or a space.
Returns a DateTime value based on the values passed in the function parameters. If time is omitted, 00:00:00.000000 (midnight) is used by default.
The following examples demonstrate typical syntax/usage for this function.
Syntax 1
• datetime(relativedate(today(),5),17:00:00) --> evaluates to: 01/18/2015 17:00:00
• datetime(date("01/01/2015")) --> evaluates to: 01/01/2015 00:00:00
• datetime(today(),08:15:00:0000) --> evaluates to: 01/11/2015 08:15:00 (Note the seconds are rounded off without fractional seconds.)
• datetime(2010-12-15, 10:49:00) --> evaluates to: 12/15/2010 10:49:00
Syntax 2
• datetime("01/14/2015,08:15:00") --> evaluates to: 01/14/2015 08:15:00
• datetime("01-14-15 08:15:05") --> evaluates to: 01/14/2015 08:15:05
• datetime("2015/01/14,08:15:00") ---> evaluates to: 01/14/2015 08:15:00
• datetime("01-10-2015, 14:08:32") ---> evaluates to: 01/10/2015 14:08:32
• datetime("jan 10 2015 17:00:00") ---> evaluates to: 01/10/2015 17:00:00
• datetime("01/10/2015") ---> evaluates to: 01/10/2015 00:00:00
At first inspection one might think that Syntax 2 is easier and much more flexible so why even bother with Syntax 1?
However, using Syntax 2, the following function would have to be written as:
datetime(string(relativedate(today(),5),"mm/dd/yyyy") + " 17:00:00")
Using syntax 1, the same function looks like this:
datetime(relativedate(today(),5),17:00:00)