#### ToDate

##### ToDate(number or string)

Uses the function IsDate(number or string) to check whether the number/string is right or not. If the number/string is right, the function returns a Date value between 100-1-1 and 9999-12-31. If the number/string is wrong, it returns null.

Parameters

- number - A value representing the number of days starting from January 1, 1900. It can be positive or negative, and is truncated if fractional.
- string - A text string representing a date and many forms can be accepted.

Return value

Date value or null.

Examples

- `ToDate(50.5)` - Returns 1900-2-19 since fraction is truncated.
- `ToDate(-50)` - Returns 1970-01-01.
- `ToDate(22222222)` - Returns 1970-01-01.
- `ToDate("2004 2 19")` - Returns 2004-2-19.
- `ToDate("99-5")` - Returns 1999-5-1.
- `ToDate("1999-2-29")` - Returns null since 1999 is not leap year.

##### ToDate(Date a)

This function returns the specified date.

Parameter

a - A Date value.

Return value

The return value is a Date.

Example

Suppose the date is July 15, 1999, the return of the following statement is 07/15/99.

`ToDate(ToDate(1999, 7, 15))`

##### ToDate(Datetime a)

This function extracts the date portion of a specified DateTime.

Parameter

a - A TimeStamp value.

Return value

The return value is a Date value.

Example

Suppose the DateTime is July 15,1999 12:20:30, the return value of the following statement is 07/15/99.

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

##### ToDate(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 data 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 Date.

Example

The return value of the following statement is 01/02/70.

`ToDate(72000000)`

Note: When the milliseconds value is larger than 2³², you should use DBField or parameter instead.

##### ToDate(integer y, Integer m, Integer d)

This function creates a Date 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 Date.

Example

The return value of the following statement is 07/15/99.

`ToDate(1999, 7, 15)`