Asp.Net

Tuesday, 29 October 2013

Difference between two dates in C#!!

Console Applications:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {

            DateTime d1 = DateTime.Now;
            DateTime d2 = DateTime.Now.AddDays(2);
            TimeSpan span = d2 - d1;
            Console.WriteLine("There're {0} days between {1} and {2}", span.TotalDays, d1.ToString(), d2.ToString());
            Console.ReadLine();
          
        }
    }
}

No comments:

Post a Comment