to_date

Converts an expression to date and time based on the format specified.

Available in:

Apps (win) Apps (char) Reportwriter RPC Standalone PL
X X X X X

Syntax

datetime to_date(data[,format])
expr             data
string           format

Description

If data cannot be converted to format, the conversion fails and an error is returned. If data is already a date, no conversion occurs and the original value is returned.
data specifies the expression to convert.

format (optional) specifies a mask. If none is provided, a default conversion is performed. Refer to the VORTEX Installation and Usage Guide for the valid formats.

Example

Formats date in European format.
field = to_date(G.TIME,"DD/MM/YY");

Rdb

Formats date to include hours, minutes, and seconds.
{
list     t1;
char     td1[25];
char     td2[25];
datetime dd1;
datetime dd2;
/****************************************************************/
/* Pass datetime variable into SELECT statement for Rdb         */
/****************************************************************/
dd1 = to_date("01-FEB-1992 00:00:00","DD-MON-YYYY HH:MI:SS");
dd2 = to_date("15-FEB-1992 00:00:00","DD-MON-YYYY HH:MI:SS");

/* -----   ship_dt is DATE type of Rdb   ----- */
t1 = list_open("SELECT custid,ship_dt FROM tk_ship WHERE ship_dt BETWEEN "
               " '" ^^ to_char(dd1,"DD-MON-YYYY HH:MI:SS") ^^ "' and "
               " '" ^^ to_char(dd2,"DD-MON-YYYY HH:MI:SS") ^^ "' ",1000);
list_view(t1,0);
/***************************************************************/
/* Hard code data into SELECT statement for Rdb                */
/***************************************************************/
t1 = list_open("SELECT custid,ship_dt FROM tk_ship WHERE ship_dt BETWEEN "
               " '" ^^ "01-FEB-1992 00:00:00.00" ^^ "'  and "
               " '" ^^ "15-FEB-1992 00:00:00.00" ^^ "'   ",1000);
list_view(t1,0);
}