In C#, DateTime.Add takes a TimeSpan and returns a newDateTime that is that far from the original. A positive span moves forward; a negative span moves back.
Use Add when you already have a TimeSpan, for example the result of another subtraction. If you only have a number of days or hours, AddDays and AddHours are shorter.
This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.Add(...). DateTime is a struct, so every value is copied and never changed in place.
Syntax
Call Add on a DateTime value and pass a TimeSpan.
C#
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime a = dt.Add(new TimeSpan(2, 15, 30)); // +2h 15m 30s
DateTime b = dt.Add(TimeSpan.FromDays(1)); // +1 day
DateTime c = dt.Add(TimeSpan.FromHours(-20)); // back 20 hours
Call
What it does
dt.Add(new TimeSpan(2, 15, 30))
Move forward by 2 hours, 15 minutes, 30 seconds.
dt.Add(TimeSpan.FromDays(1))
Move forward by one day (24 hours).
dt.Add(TimeSpan.FromHours(-20))
A negative TimeSpan moves the date back.
Add returns a result and never edits dt. If the answer would fall before DateTime.MinValue or after DateTime.MaxValue, it throws ArgumentOutOfRangeException.
Library declarations
C#
public DateTime Add(TimeSpan value);
Parameters
Parameter
Description
value
Required. A TimeSpan. It can be positive or negative and may include fractions of a second.
Return Value
Return Value
Description
DateTime
A new DateTime equal to this value plus value. It keeps the same Kind.
C# Examples
Example 1 — Add a TimeSpan
Move a fixed time forward and show that the original value is unchanged.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
TimeSpan gap = new TimeSpan(2, 15, 30);
DateTime later = dt.Add(gap);
Console.WriteLine(Show(dt));
Console.WriteLine(Show(later));
}
}
Output
2026-11-18 14:30:45
2026-11-18 16:46:15
How It Works
Build a span.new TimeSpan(2, 15, 30) means 2 hours, 15 minutes, 30 seconds.
Add it. 14:30:45 plus 2:15:30 gives 16:46:15 on the same day.
Original kept. The first line still shows 14:30:45 because Add returns a new value.
Helper method.Show prints a fixed pattern so the output never depends on your culture.
Example 2 — Negative TimeSpan
Pass a negative span to move to the previous day.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime earlier = dt.Add(TimeSpan.FromHours(-20));
Console.WriteLine(Show(earlier));
Console.WriteLine(earlier.Date == dt.Date);
}
}
Output
2026-11-17 18:30:45
False
How It Works
Minus 20 hours.TimeSpan.FromHours(-20) is a span that points backward.
Cross midnight. 14:30:45 minus 20 hours lands at 18:30:45 on November 17.
Date part changed. The Date property now differs, so the comparison prints False.
Same as Subtract.dt.Add(-span) and dt.Subtract(span) give the same answer.
Example 3 — Roll into the Next Year
Add hours at the end of December and add a zero span.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
DateTime nye = new DateTime(2026, 12, 31, 22, 0, 0);
DateTime after = nye.Add(TimeSpan.FromHours(5));
DateTime same = nye.Add(TimeSpan.Zero);
Console.WriteLine(Show(after));
Console.WriteLine(same == nye);
}
}
Output
2027-01-01 03:00:00
True
How It Works
New Year's Eve. The start value is December 31, 2026 at 22:00.
Five hours later. The result crosses midnight and the year number changes to 2027.
Zero span.TimeSpan.Zero adds nothing, so the new value equals the old one.
Equality check.== compares ticks, so it prints True.
Frequently Asked Questions
No. DateTime is immutable. Add returns a new DateTime, so assign it to a variable to keep it.
Add takes a TimeSpan. AddDays takes a double number of days. Both return a new DateTime.
Yes. A negative TimeSpan moves the date backward.
No. Add works on ticks only. Use TimeZoneInfo conversions when you need daylight saving rules.
It throws ArgumentOutOfRangeException when the result is before DateTime.MinValue or after DateTime.MaxValue.