Wednesday, 19 March 2014

Calculate Days,Month and Year from To and From Dates

 const double daysToMonths = 30.4368499;
              
                if (dtOne != null &&  dtTwo != null)
                {
                    if (dtTwo.Value > dtOne.Value)
                    {
                        double days = (dtTwo.Value - dtOne.Value).TotalDays;                       
                        double months = Math.Round(days / daysToMonths);                       
                        double years = dtTwo.Value.Year - dtOne.Value.Year;
            }

No comments:

Post a Comment