formatDateDatabase

Formats the date and time in preparation for an SQL query. Long-formatted dates cannot be evaluated (for example, May 22, 2000).

Type and Usage

Parameters

The only parameter is a string or variable that specifies a date/time.

Output

  • Returns an ODBC-formatted date/time:

    [ts 'yyyy-mm-dd hh:mm:ss']
    
  • Returns null if the parameter cannot be evaluated.

  • If a time is not provided, returns a default time of 00:00:00.

Example

Formats the current date and time for an SQL query:

<$formatDateDatabase(dateCurrent())$>

Formats the date and time and displays as 2001-03-19 15:32:00:

<$formatDateDatabase("03/19/2001 3:32 PM")$>

Formats the date and time and displays as 1999-04-03 00:00:00:

<$formatDateDatabase("4/3/99")$>