I have forgotten
my Password

Or login with:

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

date Diff360

viewed 2364 times and licensed 154 times
Computes the number of days between two serial dates using a 360 day accounting years. \begin{html}Excel: DAYS360\end{html}
Controller: CodeCogs

Dependents

Info

Interface

C++

DateDiff360

 
intdateDiff360intstartDate
intendDate
dateDiffTypetype = dd_USA )
Returns the number of days between two serial Julian dates based on a 360-day year (twelve 30-day months), which is used in some accounting calculations, where each month is assumed to have 30-days. You might use this function to compute employee payments if your accounting system is based on twelve 30-day months.

To facilitate the new month lengths, the dates entered may need to be adjusted, such that months with 31 days are assumed to have 30, while February is extended. These calculation are performed within the confines of the Gregorian calendar, nevertheless Europe and the USA each have their own methodologies for adjusting dates that occur at the end of the month,
TypeDescription
dd_EuropeStart or end dates that occur on the 31st of a month become equal to the 30th of the same month.
dd_USAThis is identical to the European system with one exception that applies only to end dates: If the end date occurs on the 31st of a month it is moved to the 1st of the next month if the start date is earlier than the 30th. This method is sometime also called the 'NASD' method.

Having made these adjustments to the start and end dates, the difference between these is calculated using: where the subscripts refer to the start and end date with attributes day, month, and year.

Example 1

#include <stdio.h>
#include <codecogs/units/date/datediff360.h>
#include <codecogs/units/date/date.h>
using namespace Units::Date;
 
int main()
{
  printf("\n Diff 360=%d days", dateDiff360(date("27-2-2004"), date("20-8-2005")));   // 533
  printf("\n Diff 360=%d days", dateDiff360(date("28-2-2004"), date("20-8-2005")));   // 532
  printf("\n Diff 360=%d days", dateDiff360(date("29-2-2004"), date("20-8-2005")));   // 530
  printf("\n Diff 360=%d days", dateDiff360(date("1-3-2004"),  date("20-8-2005")));   // 529
 
  printf("\n\n Diff 360=%d days", dateDiff360(date("29-3-2004"), date("20-8-2005"))); // 501
  printf("\n Diff 360=%d days", dateDiff360(date("30-3-2004"), date("20-8-2005")));   // 500
  printf("\n Diff 360=%d days", dateDiff360(date("31-3-2004"), date("20-8-2005")));   // 500
  printf("\n Diff 360=%d days", dateDiff360(date("32-3-2004"), date("20-8-2005")));   // 499
 
  printf("\n\n Diff 360=%d days", dateDiff360(date("15-3-2004"), date("30-10-2005")));// 585
  printf("\n Diff 360=%d days", dateDiff360(date("16-3-2004"), date("31-10-2005")));  // 585
  printf("\n Diff 360=%d days", dateDiff360(date("29-3-2004"), date("30-10-2005")));  // 571
  printf("\n Diff 360=%d days", dateDiff360(date("31-3-2004"), date("31-10-2005")));  // 570
 
  printf("\n\n Diff 360=%d days", dateDiff360(date("28-2-2004"), date("31-10-2005")));// 603
  printf("\n Diff 360=%d days", dateDiff360(date("29-2-2004"), date("31-10-2005")));  // 601
  return 0;
}

  • dd_European
  • dd_USA (default)

Parameters

startDateand...
endDateare serial Julian dates (see date ). The return value is signed, so if startDate occurs before endDate then a negative answer will be returned. See date , for details on creating these numbers.
typedefines which accounting date system to use:
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

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