Wednesday, 28 October 2015

C# Program to Compare Two Dates?

 class Program
    {
        static int Main()
        {
            DateTime sd = new DateTime(2012, 09, 12);
            Console.WriteLine("Starting Date : {0}", sd);
            DateTime ed = sd.AddDays(10);
            Console.WriteLine("Ending Date   : {0}", ed);
            if (sd < ed)
                Console.WriteLine("{0} Occurs Before {1}", sd, ed);
            Console.Read();
            return 0;

        }
    }
-----------------------
OUTPUT
Starting Date : 09/12/2012    12:00:00 AM
Ending Date   : 09/21/2012   12:00:00 AM
09/12/2012    12:00:00 AM Occurs Before 09/21/2012   12:00:00 AM
--------------------

No comments:

Post a Comment