datetime PowerHome formula function
Description
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.

Syntax 1 (Separate date and time datatypes)
 datetime ( date {, time } )
Argument Description
date A valid date value (function output eg, date() or a date 'literal' value such as 2010-12-15)
time (optional) A valid time value (function output eg, time() or time 'literal' such as 10:25:23:456).

Syntax 2 (A single string)
 datetime ( dtstring )
Argument Description
dtstring A string containing a valid date or datetime. This string can contain the date in a variety of formats and can have the optional time separated by a comma or a space character. See the date() and time() functions for valid formats

Return value
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.

Examples
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)