Computes the number of days between two serial dates using a 360 day accounting years. \begin{html}<span align="right" style="background-color:99FF99"><strong>Excel: DAYS360</strong></span>\end{html}

View versions (1)

Interface

#include <codecogs/units/date/datediff360.h>

using namespace Units::Date;

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, \copydoc date/constants dateDiffType

Having made these adjustments to the start and end dates, the difference between these is calculated using:

dateDiff = \begin{array}{l} \left (day_{end} + 30 month_{end} + 360 year_{end} \right ) \\ - \left (day_{start} + 30 month_{start} + 360 year_{start} \right ) \end{array}
(1)

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;
}

Parameters

startDate
and...
endDate
are 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.
type
defines which accounting date system to use:
Blank
  • dd_European
  • dd_USA (default)
GPL Licence — free for non commercial use. See Licence details.