I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
COST (GBP)
this unit 2.81
sub units 6.68
+
0
UnitsDate

end Of Month

Advances a serial date to the last day of the month after adding \a months. Excel: EOMONTH
Controller: CodeCogs

add cart

Dependents

Info

Interface

C++
HTML

EndOfMonth

 
intendOfMonthintnDate
intmonths
calendardateSystem = cal_Gregorian )[inline]
Returns the serial Julian date which equals the last day of the month for nDate plus or minus the offset provided by months.

The month is modified using: Month_{new} = Month_{old} + Months. The day part of nDate is always overwritten with the maximum number of days in the new month.

Example 1

#include <stdio.h>
#include <codecogs/units/date/endofmonth.h>
#include <codecogs/units/date/date.h>

using namespace Units::Date;   int main() { for(int i=-2; i<=2; i++) { int d,m,y; dateYMD(endOfMonth(date("19,feb,2003"), i), y, m, d); printf("\n Month end for 19 February 2003 + %d months is: %d-%d-%d",i, d, m, y); }

for(int i=-2; i<=2; i++) { int d,m,y; dateYMD(endOfMonth(date("31,dec,2004"), i), y, m, d); printf("\n Month end for 31 December 2004 + %d months is: %d-%d-%d",i, d, m, y); } return 0; }
Output:
Month end for 19 February 2003 + -2 months is:  31-12-2002
Month end for 19 February 2003 + -1 months is:  31-1-2003
Month end for 19 February 2003 + 0 months is:  28-2-2003
Month end for 19 February 2003 + 1 months is:  31-3-2003
Month end for 19 February 2003 + 2 months is:  30-4-2003
 
Month end for 31 December 2004 + -2 months is:  31-10-2004
Month end for 31 December 2004 + -1 months is:  30-11-2004
Month end for 31 December 2004 + 0 months is:  31-12-2004
Month end for 31 December 2004 + 1 months is:  31-1-2005
Month end for 31 December 2004 + 2 months is:  28-2-2005

  • cal_Gregorian (default)
  • cal_Julian
  • cal_Excel (same as Gregorian)

Parameters

nDateis the number of days from 24 November 4714 BC - otherwise known as the Julian Period (also 1 January 4713BC in the Julian Calendar).
monthsare the number of months to add (a positive value) or subtract (a negative value) from nDate.
dateSystemselects which date system should be used (see constants):

Authors

Will Bateman (Sep 2004)
Source Code

Source code is available when you buy a Commercial licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.