Function CtoD() Foundation
Converts a date character string to a date value.
CtoD( <cDate>[, <cDateFormat>] ) --> dDate
CtoD() returns a date value. When <cDate> is an invalid date, CtoD() returns an empty date.
CtoD() converts a character string to a date value. Date values can only be created using CtoD(), StoD() and Date(). To create an empty date value (such as to prepare for date input), a null string (""), Space(8), or " / / " must be passed as <cDate> to CtoD(). Note that the exact format of the character string and the delimiters contained in the string depends on the date format selected via the <cDateFormat> parameter.
CtoD() is used when literal date values must be converted to a date value in a program. The counterpart function DtoC() reverses the function CtoD().
// The example demonstrates the result of the conversion of a
// character string to a date value dependent on SET DATE
PROCEDURE Main
// Select German date format
SET DATE GERMAN
? CMonth( CtoD( "12.06.94" ) ) // -> "June"
? CMonth( CtoD( "06/12/94", "mm/dd/yy" ) ) // -> "June"
// Select US date format
SET DATE AMERICAN
? CMonth( CtoD( "12/06/94" ) ) // -> "December"
RETURN
// In the example, two variables are initialized
// with the function CtoD() to an empty date value
// prior to editing in two GET fields.
PROCEDURE Main
dArrival := CtoD("")
dDeparture := CtoD("")
@ 10, 10 SAY "Arrival:" GET dArrival ;
RANGE Date() , Date()+365
@ 12, 10 SAY "Departure:" GET dDeparture ;
RANGE dArrival , dArrival+365
READ
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.