Xbasic

CTOD Function

Syntax

Date_Value as D = CTOD(C character)

Arguments

character

A variable containing a date value or a character string containing a legitimate representation of a date value ( < span class=Code1>ISDATE (Date_Representation) = .T. ).

Description

Converts a character string to a date value.

Discussion

CTOD() returns a Date value extracted from a character string. For more information about date formats, see the DATE_FORMAT()function. The two most frequent uses of CTOD() are: searching and filtering date fields, and converting character fields containing dates into real date fields. Note : If the setting for Fully Specified Years requires all dates to be fully specified CTOD returns a blank value for years specified as 2 numbers.

Assume that you just re-configured an existing table to add a new date field called START_DATE. This field is initially blank for all the records, so you want to put the date "12/12/95" in all the records. Instead of editing each record individually, use the Update builder to update all of the records at once with an operation. You can define the following update expression for START_DATE:

ctod("12/12/95")

The quotation marks are necessary to indicate that the data inside the parentheses is character data. CTOD converts the character date string to a date field type so that you can insert it into START_DATE. Note : A convenient alternative to CTOD() is enclosing the date values (without quotation marks) in curly brackets (e.g., {12/12/95}).

See Also