#### ToDateTime

##### ToDateTime(number or string)

Use the function IsDateTime to check whether the number/string is right or not. If it is right, the function returns a DateTime value between 100-1-1 and 9999-12-31, otherwise the function returns null.

Parameters

- number - A Number value or expression to be tested for convertibility to a DateTime value. It can be positive, negative or fractional. It is interpreted as a number of days from Jan 1, 1900.
- string - A String value or expression to be tested for convertibility to a DateTime value. Many forms are accepted.

Return value

DateTime value or null.

Examples

- `ToDateTime(255.35)` - Returns 1900-09-12 08:23:59.
- `ToDateTime("Jan 3, 2004")` - Returns 2004-01-03 00:00:00.
- `ToDateTime("5:25:26pm")` - Returns 2004-02-23 17:25:26 because the current date is 2004-2-23.
- `ToDateTime("2003-2-29 15:26:25")` - Returns null because the given String value is not right DateTime value.
- `ToDateTime("2004 *2 *29 15:26:25")` - Returns null because the given String format is not right DateTime format.

##### ToDateTime(date)

Returns a DateTime value.

Parameter

date - A Date value that can be converted to a DateTime type value by this function.

Example

`ToDateTime(ToDate("2004-2-23"))` - Returns 2004-02-23 00:00:00.

##### ToDateTime(Date a, Time b)

This function creates a TimeStamp value from arguments a and b.

Parameters

- a - A Date value.
- b - A Time value.

Return value

The return value is a DateTime.

Example

Suppose the date is July 15,1999 and the time is 12:20:30, the return value of the following statement is 1999-07-15 12:20:30.

`ToDateTime(ToDate(1999, 7, 15), ToTime(12, 20, 30))`

##### ToDateTime(Integer d)

This function converts the argument d (A milliseconds value represents the number of milliseconds that have passed since January 1, 1970 00:00:00.000 GMT) to a TimeStamp value.

Parameter

d - A Milliseconds value, a DBField value or a parameter. It should be a long integer.

Return value

The return value is a DateTime.

Example

The return value of the following statement is 1970-01-02 04:00:00.

`ToDateTime(72000000)`

Notes:

- In this function, you can decide the display format by selecting the format from the Report Inspector. The format of the example above is yyyy-mm-dd hh:mm:ss.
- When the milliseconds value is larger than 2³², you should use DBField or parameter instead.

##### ToDateTime(Integer y, Integer m, Integer d)

This function creates a TimeStamp value from arguments y, m and d.

Parameters

- y - A BigInt value indicating year.
- m - A BigInt value indicating month.
- d - A BigInt value indicating day.

Return value

The return value is a DateTime.

Example

Suppose the date is July 15,1999, the return value of the following statement is 1999-07-15 12:00:00.

`ToDateTime(1999, 7, 15)`

Note: In this function, because you only input year, month and day, the system will output 12:00:00 as the default time. Also you can decide the display format by selecting the format from the Report Inspector. The format of the example above is yyyy-mm-dd hh:mm:ss.

##### ToDateTime(Integer y, Integer m, Integer d, Integer h, Integer i, Integer s)

This function creates a TimeStamp value from arguments y, m, d, h, i and s.

Parameters

- y - A BigInt value indicating year.
- m - A BigInt value indicating month.
- d - A BigInt value indicating day.
- h - A BigInt value indicating hour.
- i - A BigInt value indicating minute.
- s - a BigInt value indicating second.

Return value

The return value is a DateTime.

Example

Suppose the date is July 15,1999 and time is 8:05:30, the return value of the following statement is 1999-07-15 08:05:30.

`ToDateTime(1999, 7, 15, 8, 5, 30)`