CDoW(), CMonth(), Day(), Month(), Year(), Quarter()

These functions return the character and numeric equivalents of the date or datetime supplied.

Usage

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.

Example

? 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

See Also

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()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .