monthmath(
monthmath(
DATE
,
OFFSET
)

The monthmath( function takes a date and computes the date that is one or more months before or after the original date.

Parameters

This function has two parameters:

date – is a number representing the original date.

offset – is the number of months to add or subtract from the date.

Description

This function offsets a date by a number of months. For example, if you offset the date May 12, 1997 by two months the result is July 12, 1997. If you offset the same original date by minus two months the result is March 12, 1997.

If the new date does not exist because a month does not have enough days in it, the monthmath( function will pick the last day of the month. For example, if you offset March 31 by 1 month the result is April 30. If the new month lands in February the function knows about leap years and adjusts accordingly.

    datepattern(monthmath(date("mar 31, 2012"),1),"Month ddnth, YYYY") ☞ April 30th, 2012
    datepattern(monthmath(date("mar 31, 2012"),-1),"Month ddnth, YYYY") ☞ February 29th, 2012
    datepattern(monthmath(date("mar 31, 2012"),2),"Month ddnth, YYYY") ☞ May 31st, 2012
    datepattern(monthmath(date("mar 31, 2012"),12),"Month ddnth, YYYY") ☞ March 31st, 2013

Note: These examples assume the system’s Date & Time preferences are set to US format. If a non-US format is being used, the date values would have to be adjusted.

See Also

- calendardate( -- helps in creating monthly calendars.
- calendarday( -- helps in creating monthly calendars.
- Date Patterns -- control how dates are displayed or converted to text.
- date( -- converts text into a number representing a date.
- datepattern( -- converts a number representing a date into text. The function uses a pattern to control how the date is formatted (see Date Patterns).
- datevalue( -- converts integer values for year, month and day into a number representing a date.
- dayofweek( -- computes the day of the week, with Sunday being 0, Monday 1, etc.
- dayvalue( -- extracts the day from a date as a numeric value.
- firstdayofweek( -- returns the user's preference for first day of the week.
- groupdatepattern( -- converts a number representing a date into text in a special format for use with the summarytable( and crosstab( functions. The function uses a pattern to control how the date is formatted (see Date Patterns).
- month1st( -- computes the first day of a month.
- monthlength( -- computes the length (number of days) of a month.
- monthvalue( -- extracts the month from a date as a numeric value.
- naturaldate( -- converts a number representing a date into text using "natural" formatting.
- quarter1st( -- computes the first day of a quarter.
- quartervalue( -- extracts the quarter from a date as a numeric value.
- regulardate( -- extracts a regular date (number of days from January 1, 4713 B.C.) from a superdate.
- superdate( -- converts a regular date and a regular time into a superdate.
- superdatepattern( -- converts a number containing a superdate to text, allowing you to specify the patterns for both the date and the time conversion to text.
- superdatesecondsstr( -- converts a number containing a superdate to text, including the seconds.
- superdatestr( -- converts a number containing a superdate (date + time) to text.
- supernow( -- returns the number representing the current date and time as a superdate.
- today( -- returns a number corresponding to today's date.
- week1st( -- computes the first day of a week (Sunday).
- weekvalue( -- extracts the week from a date as a numeric value.
- year1st( -- computes the first day of a year.
- yearvalue( -- extracts the year from a date as a numeric value.

History

Version | Status | Notes
10.0 | No Change | Carried over from Panorama 6.0