Days Between - CSharp System

CSharp examples for System:DateTime Day

Description

Days Between

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from  ww w  .j a v a  2  s . co m

public class Main{
        public static int DaysBetween(this DateTime dt, DateTime dt2, bool includeLastDay)
        {
            int days = dt.DaysBetween(dt2);
            if (!includeLastDay) return days;
            return days + 1;
        }
        public static int DaysBetween(this DateTime dt, DateTime dt2)
        {
            return (dt2.Date - dt.Date).Duration().Days;
        }
}

Related Tutorials