Hi,
你好
There are a lot of written methos of getting the difference between two dates, but I couldn't find the one I needed. I need to have a real difference like 3.75 months between the two dates.
有很多书面方法来获取两个日期之间的差额,但我找不到我需要的日期。 我需要在两个日期之间有一个真正的区别,例如3.75个月。
Not every month has the same amount of days and the February is also an issue here. So I made myself a method doing this:
并非每个月都有相同的天数,因此2月也是一个问题。 所以我自己做了一个方法:
/// <summary>
/// Get months difference between two dates
/// </summary>
/// <param name="from">from date</param>
/// <param name="to">to date</param>
/// <returns>months (double) between </returns>
internal static double GetMonths(DateTime from, DateTime to)
{
/// |-------X----|---------------|--------