C# program to add and subtract days from the date

In this C# program, we will add and subtract days from the date.

C# program to add and subtract days from the date Code:

private static void Main(string[] args)
        {
            DateTime StartDate = new DateTime(2022, 1, 1);
            DateTime tempDate = StartDate;
            Console.WriteLine("Initial Date : {0}", StartDate);
            Console.WriteLine();

            //--- Add Days to the date
            DateTime ADate = tempDate.AddDays(10);
            Console.WriteLine("Date after adding 10 days to date : {0}", ADate);

            //--- Subtract Days to the date
            tempDate = StartDate;
            DateTime SDate = tempDate.AddDays(-10);
            Console.WriteLine("Date after subtracting 10 days to date : {0}", SDate);

            Console.ReadLine();
        }

C# program to add and subtract days from the date Output:

CSharp-program-to-add-and-subtract-days-from-the-date

 
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
1 + 2 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2022 CodingFusion
75 Important SQL Server queries you should know