Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
CDOW()
, CMONTH()
, DAY()
, MONTH()
, YEAR()
, QUARTER()
These functions return the character and numeric equivalents of the date or datetime supplied.
cRetVal = CDOW( dDate | tDateTime )
cRetVal = CMONTH( dDate | tDateTime )
nRetVal = DAY( dDate | tDateTime )
nRetVal = MONTH( dDate | tDateTime )
nRetVal = YEAR( dDate | tDateTime )
nRetVal = QUARTER( dDate | tDateTime [, nFirstMonth ] )
CDOW()
and CMONTH()
display the current day (“Saturday”) and month (“December”). The return values are always in Proper format: capitalized first letter, lowercase for the remainder. Use these functions for output only, and not for internal business logic, if your application will be used in multi-lingual settings where one man’s Thursday can be another’s Donnerstag.
DAY()
, MONTH()
and YEAR()
return the numeric equivalents of the day of the month, month and year, based on the date or datetime supplied. They are absolute—they are based on the Gregorian calendar, a generally agreed-upon standard. YEAR()
always returns the full year, including century, regardless of the setting of CENTURY. Two other similar functions, DOW()
and WEEK()
, are discussed in their own section, as they depend on the system settings of the “first week of the year” and the “first day of the week.”
QUARTER()
, new in VFP 7, returns the numeric quarter of the year for the specified date or datetime. The optional nFirstMonth parameter lets you specify the starting month for the year.
Be forewarned. The functions in this group that return numeric values return them as numbers, not integers. That means that if you SET FIXED
ON, you’re going to see decimal places in the day, month, year and quarter. Probably not what you expected.
? CDOW(DATE()) && The equivalent of "What day is it?"
? CMONTH(DATETIME()) && and "What month is it?"
? DAY({^ 1995/06/15}) && Returns 15
? MONTH({^1995/06/15}) && Returns 6
? YEAR({^1995/06/15}) && Returns 1995
? QUARTER({^1995/06/15}) && Returns 2
? QUARTER({^1995/06/15}, 7) && Returns 4
DoW(), Date(), DateTime(), DMY(), MDY(), GoMonth(), Set Century, Set Date, Set FDoW, Set FWeek, Set Fixed, Set Mark To, Sys(1), Sys(10), Sys(11), Week()