Convert name of day of the week to its ordinal number
CToDoW( <cDayName> ) -> <nOrdinal>
<cDayName> Name of day to convert to ordinal number
<nOrdinal> Ordinal number of <cDayName>
Use CToDoW() to change the name of a day of the week to a number. Sunday corresponds to 1, Monday 2, etc.. If the function returns a 0 value, an invalid parameter has been passed. You can shorten the day names, but these abbreviations must be explicit to return an accurate value.
. Uppercase and lowercase letters do not affect the name of the day of the week. . The function’s operation depends on the country-specific adaptation of your CA-Clipper compiler. With an English version of CA-Clipper, only English day names are recognized.
PROC MAIN() SETMODE( 25, 80 ) CLS SET DATE GERM SET CENT ON ? "CToDoW('Sunday') :", CToDoW('Sunday') // 1 * Show several ways to get the day of * the week for Wednesday: ? "CToDoW('WEDNESDAY') :", CToDoW('WEDNESDAY') // 4 ? "CToDoW('Wednesday') :", CToDoW('Wednesday') // 4 ? "CToDoW('Wed') :",CToDoW('Wed') // 4 * What number of the day of the week is Monday? ? "CToDoW( 'M' ) :", CToDoW( 'M' ) // 2 ? WAIT "EOF CTODOW.prg" RETURN // MAIN
CToDoW() is compatible with CT3’s CToDoW().
Source is dattime2.prg, library is libct.