Days Count - CSharp System

CSharp examples for System:DateTime Day

Description

Days Count

Demo Code


using System.Globalization;
using System;//from w ww. j a  v a2  s  . co  m

public class Main{
        public static int DaysCount(DateTime? startDate, DateTime? endDate)
        {
            if (startDate.HasValue && endDate.HasValue)
            {
                var span = endDate.Value - startDate.Value;
                var result = span.Days + 1;
                return result;
            }

            return 0;
        }
}

Related Tutorials