Answers for "calculate the exact days and months between two dates c#"

C#
12

c# calculate difference between two dates in days

(EndDate - StartDate).TotalDays //double
(EndDate.Date - StartDate.Date).Days //int
Posted by: Guest on June-07-2020
3

total months between two dates c#

((date1.Year - date2.Year) * 12) + date1.Month - date2.Month
Posted by: Guest on December-30-2020
0

convert number of days into months c#

//This function is meant for general conversions only.  
//Converting the months between two known date ranges may cause odd results
private int ConvertDaysToMonths(double days)
{
  // Divide by this constant to convert days to months.
  const double daysToMonths = 30.4368499;

  return Convert.ToInt32(Math.Floor(days / daysToMonths));
}
Posted by: Guest on June-21-2020

Code answers related to "calculate the exact days and months between two dates c#"

C# Answers by Framework

Browse Popular Code Answers by Language