CToD(), DToC(), DToS()
These functions convert
character strings to dates, dates to characters, and dates to
character strings in system (YYYYMMDD) format, respectively. All
the functions respect the settings of CENTURY, DATE and MARK, so
make no assumptions about the placement of particular characters
or the exact delimiters used, unless you explicitly SET them
first.
Usage
|
dRetVal = CTOD( cDate )
cRetVal = DTOC( dDate | tDateTime [, 1 ] )
cRetVal = DTOS( dDate | tDateTime )
|
CTOD() converts a character expression to a date. CTOD()
lets you omit zeros before numbers and translates any of the
common delimiters ( /, -, . ) regardless of the current setting
of DATE or MARK.DTOC() converts a date or datetime to a character
string, using the current DATE, MARK and CENTURY format. The
optional 1 in the second parameter (actually, any parameter will
do—logical, numeric, string, or even .NULL.!) outputs the string
in DTOS() format (see below) rather than the current default.
Only the date portion of a datetime variable is returned—see
TTOC() to get the full datetime value in character form. Without
the second parameter, the return value of DTOC() can vary from 8
to 10 characters, depending on the settings of CENTURY. DTOS()
converts a date or datetime to a character string of the format
YYYYMMDD. This is a format handy for creating indexes, since all
dates get listed chronologically. Only the date portion of a
datetime variable is returned—see TTOC() to get the full datetime
value in character form.
Example
|
cSetDate = SET("DATE")
SET DATE MDY
dRetVal = CTOD(ltrim(str(nMonth))+"/01/1900")
SET DATE &cSetDate
cRetVal = DTOC(datetime())
cRetVal = DTOS(DATE())
|
See Also
|
CDoW(), CMonth(), DoW(), Date(),
DMY(), MDY(), GoMonth(), Set
Century, Set Date, Set Mark To, TToC()
|
Back to Table of Contents
Copyright © 2002-2018 by Tamar E. Granor,
Ted Roche, Doug Hennig, and Della Martin. Click for license
.