xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CtoD()

Converts a character string into a Date value

Syntax

CtoD( <cDateString> ) --> dDate

Arguments

<cDateString>
This is a character string formatted as a date. Digits for day, month and year plus the separator sign must comply with the current SET DATE format. If the year is not given as a four digit number, the rules for SET EPOCH apply for the date conversion.

Return

The function returns the converted Date value. If <cDateString> is not a valid date string, an empty date is returned.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe