xHarbour Reference Documentation > Function Reference |
Converts a character string into a Date value
CtoD( <cDateString> ) --> dDate
The function returns the converted Date value. If <cDateString> is not a valid date string, an empty date is returned.
The conversion function CtoD() is used to create date values from string literals formatted as a Date. Formatting of the string literal must comply with the current SET DATE format. That is, digits for day, month and year in <cDateString> are interpreted according to the sequence of the letters dd, mm and yy in the SET DATE format string.
The conversion rules of SET EPOCH apply for the year when it is not specified with four digits.
Use function StoD() to convert a string to a date value independently of SET DATE.
See also: | Date(), DtoC(), DtoS(), SET CENTURY, SET DATE, SET EPOCH, StoD(), TtoC() |
Category: | Conversion functions , Date and time |
Source: | rtl\dateshb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example outlines the importance of the SET DATE format // for the conversion of string literals to Date values. PROCEDURE Main SET DATE ITALIAN // select Italian date format ? CMonth( CtoD( "05-01-06" ) ) // result: January SET DATE AMERICAN // select US date format ? CMonth( CtoD( "05/01/06" ) ) // result: May RETURN
http://www.xHarbour.com