C# program to display the next day

To display the next day in C#, use the AddDays() method with a value of 1. The AddDays() method adds or subtracts days from a DateTime object and returns a new DateTime representing the modified date.

Syntax

Following is the syntax for using AddDays() method −

DateTime.AddDays(double value)

Parameters

  • value − A number of whole and fractional days. Use positive values for future dates and negative values for past dates.

Return Value

The method returns a new DateTime object that represents the date and time with the specified number of days added.

Using DateTime.Today to Get Current Date

First, get the current date using DateTime.Today, which returns today's date with time set to 00:00:00 −

DateTime.Today

To get tomorrow's date, add 1 day using the AddDays() method −

DateTime.Today.AddDays(1)

AddDays() Method Yesterday AddDays(-1) Today DateTime.Today Tomorrow AddDays(1) AddDays() returns a new DateTime object

Example

using System;

public class Demo {
   public static void Main() {
      Console.WriteLine("Today = {0}", DateTime.Today);
      Console.WriteLine("Previous Day = {0}", DateTime.Today.AddDays(-1));
      Console.WriteLine("Next Day (Tomorrow) = {0}", DateTime.Today.AddDays(1));
   }
}

The output of the above code is −

Today = 9/4/2018 12:00:00 AM
Previous Day = 9/3/2018 12:00:00 AM
Next Day (Tomorrow) = {0}", DateTime.Today.AddDays(1));
   }
}

Using AddDays() with Different Values

Example

using System;

public class DateExample {
   public static void Main() {
      DateTime currentDate = DateTime.Today;
      
      Console.WriteLine("Current Date: " + currentDate.ToShortDateString());
      Console.WriteLine("Tomorrow: " + currentDate.AddDays(1).ToShortDateString());
      Console.WriteLine("Next Week: " + currentDate.AddDays(7).ToShortDateString());
      Console.WriteLine("Next Month (approx): " + currentDate.AddDays(30).ToShortDateString());
   }
}

The output of the above code is −

Current Date: 9/4/2018
Tomorrow: 9/5/2018
Next Week: 9/11/2018
Next Month (approx): 10/4/2018

Conclusion

The AddDays() method in C# provides an easy way to calculate dates by adding or subtracting days from a DateTime object. Use AddDays(1) to get tomorrow's date and negative values to get previous dates.

Updated on: 2026-03-17T07:04:35+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements