Library functions: date calculations

Date functions deal with strings, even though they interpret them in a very specific way.

The functions in this category are influenced by the values of a few predefined variables:

MONTHS

is a string of 12 words, separated by blanks or commas, used as values returned by the function CMONTH; for example, if you want CMONTH to return 3-character long strings, set MONTHS to the following:

MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" 
DAYS

is a string of 7 words, separated by blanks or commas, used as values returned by the function CDOW; for example, if you want CDOW to return 3-character strings, set DAYS to the following:

DAYS = "Sun Mon Tue Wed Thu Fri Sat" 
EPOCH

this value determines how two-digit years should be interpreted in dates; if the year is lesser than the last two digits of  EPOCH, it is considered as belonging to the next century, otherwise to the present century; e.g.:

EPOCH = 1970
CONSOLELN YEAR("01/01/69")
; Result: 2069
CONSOLELN YEAR("01/01/70")
; Result: 1970
CONSOLELN YEAR("01/01/97")
; Result: 1997
DATE_TYPE

this variable determines the interpretation of the strings for all the functions operating on dates; the possible values are:

0 = americano format - mm/dd/yy[yy]
1 = european format - dd/mm/yy[yy];
2 = japanese format - yy[yy]/mm/dd;

if DATE_TYPE is set to any other value, dates are considered in european format.

The functions in this category are:

ISDATE(d)

returns a logical value that says if d is a valid date (interpreted according to DATE_TYPE)

DAY(d)

returns the day of the month (1-31), -1 if the date is wrong

DOW(d)

returns the day of the week (1 = sunday, 7 = saturday, -1 = wrong date)

CDOW(d)

returns the day of the week in word (using DAYS), an empty string if the date is wrong

DOY(d)

returns the day of the year corresponding to the date or 0 if the date is wrong

MONTH(d)

returns the month of the year (1 = january .. 12 = december, -1 = wrong date)

CMONTH(d)

returns the month of the year in word (using MONTHS), an empty string if the date is wrong

WOM(d)

returns the week from the start of the month (weeks begin on monday and end on sunday)

YEAR(d)

returns the year (on 4 digits)

WOY(d)

returns the week from the start of the year (weeks begin on monday and end on sunday)

ISLEAP(d)

returns a logical value that says if the year in d is a leap year

ADDDATE([@]d, nDays)

returns the date corresponding to d increased (or decreased) by nDays; the resulting date has the same format of d (separators, digits for year) and is empty if d is wrong

DIFFDATE(d1, d2)

returns the number of days between d1 and d2; if d2 > d1, the result is negative; if d1 or d2 are not valid dates, this function returns 0

ADDMONTH([@]d, nMonths)

returns the date corresponding to d increased (or decreased) by nMonths; returns an empty string if d is not a valid date

NEXTDAY([@]d, nDay)

returns the date corresponding to the next nDay (1-7) from date d, an empty string on error

PREVDAY([@]d, nDay)

returns the date corresponding to the previous nDay (1-7) from date d, an empty string on error

EOM([@]d)

returns the date corresponding to the end of the month, an empty string if d is not valid

BOM([@]d)

returns the date corresponding to the begin of the month, an empty string if d is not valid

CONVDATE([@]d, nCurrDateType, nNewDateType)

returns the date d converted from type nCurrDateType to type nNewDateType; separators and number of digits for the year follows the format of d; if d is not valid, returns an empty string; see DATE_TYPE for a description of the values for nCurrDateType and nNewDateType

DCONVDATE([@]d, nNewDateType)

returns the date d converted from type DATE_TYPE to type nNewDateType; separators and number of digits for the year follows the format of d; if d is not valid, returns an empty string

FULLDATE([@]d)

returns the date d with the year on 4 digits (according to EPOCH); the separators used are those in d; if d is not valid, returns an empty string. Use FULLDATE(DATE()) to obtain the current date with a 4-digit year

SHRINKDATE([@]d)

returns the date d with the least possible number of digits to represent the year (2 minimum), or an empty string if d is not valid; the separators used are those in d

Start of page Next topic Previous topic Contents Index
Midnight Lake iPhone Case Black Women Shoes Black Flat Shoes Leather Flats Black Patent Ballerinas Black Ballet Shoes Casual Shoes Black Shoes Women Balle Record Player Cufflinks Best iPhone XR Clear Cases iPhone XS/XS Max Leather Cases Sale Best iPhone 8/8 Plus Silicone Cases iPhone 7/7 Plus Cases & Screen Protector New Cases For iPhone 6/6 Plus iPhone 8 Case Sale iPhone Xr Case Online iPhone 7 Case UK Online iPhone X Case UK Sale iPhone X Case Deals iPhone Xs Case New Case For iPhone Xr UK Online Case For iPhone 8 UK Outlet Fashion Silver Cufflinks For Men Best Mens Cufflinks Outlet Online The Gold Cufflinks Shop Online Cheap Shirt Cufflinks On Sale Nice Wedding Cufflinks UK Online Top Black Cufflinks UK Online Mens Cufflinks Online Silver Cufflinks For Men Men Cufflinks UK Sale Gold Cufflinks UK Online Gold Cufflinks UK Silver Cufflinks UK Shirt Cufflinks Discount Online Mens Cufflinks Deals & Sales Girls Shoes For Dance Fashion Ballet Dance Shoes Best Ballet Flats Shoes UK Online Cheap Ballet Pointe Shoes UK Online Best Ballet Shoes Outlet Best Dance Shoes Sale Cheap Ballet Flats Sale UK Best Pointe Shoes Online UK Ballet Dance Shoes UK Shoes For Dance UK Best Ballet Slippers Shop Best Yoga Shoes Hotsell