C# DateTime AddTicks() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
DateTime

Definition

In C#, a tick is 100 nanoseconds, the smallest unit a DateTime stores. DateTime.AddTicks moves a value by a long number of ticks.

Most programs use AddSeconds or AddDays. Reach for AddTicks when you need the finest step or when you already work with raw tick counts.

This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.AddTicks(...). DateTime is a struct, so every value is copied and never changed in place.

Syntax

Pass a long tick count. The constants on TimeSpan help.

C#
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime a = dt.AddTicks(TimeSpan.TicksPerSecond * 5);   // +5 s
DateTime b = dt.AddTicks(1);                             // smallest step
DateTime c = dt.AddTicks(-TimeSpan.TicksPerMinute);      // back 1 min
CallWhat it does
dt.AddTicks(TimeSpan.TicksPerSecond * 5)Five seconds later.
dt.AddTicks(1)The smallest possible step (100 ns).
dt.AddTicks(-TimeSpan.TicksPerMinute)One minute earlier.

There are 10,000,000 ticks in a second. TimeSpan.TicksPerMillisecond, TicksPerSecond, TicksPerMinute, TicksPerHour, and TicksPerDay avoid magic numbers.

Library declarations
C#
public DateTime AddTicks(long value);

Parameters

ParameterDescription
valueRequired. Number of ticks to add as a long. Negative values go backward.

Return Value

Return ValueDescription
DateTimeA new DateTime shifted by value ticks, with the same Kind.

C# Examples

Example 1 — Add Ticks Using a Constant

Add five seconds expressed as ticks.

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 later = dt.AddTicks(TimeSpan.TicksPerSecond * 5);
        Console.WriteLine(Show(later));
        Console.WriteLine(TimeSpan.TicksPerSecond);
    }
}

How It Works

  1. Named constant. TicksPerSecond is 10,000,000, so five seconds is five times that.
  2. Seconds moved. 14:30:45 plus 5 seconds shows 14:30:50.
  3. Readable code. The constant explains the intent better than a long number.
  4. Second line. It prints the constant itself so you can see the scale.

Example 2 — The Smallest Step

Add a single tick and show it with seven fraction digits.

C#
using System;
using System.Globalization;

class Program {
    static void Main() {
        DateTime start = new DateTime(2026, 11, 18, 0, 0, 0);
        DateTime next = start.AddTicks(1);
        Console.WriteLine(next.Ticks - start.Ticks);
        Console.WriteLine(start.AddTicks(5000).ToString("ss.fffffff", CultureInfo.InvariantCulture));
    }
}

How It Works

  1. One tick. The smallest change a DateTime can represent is 1.
  2. Subtract Ticks. The difference of the two Ticks values is exactly 1.
  3. 5000 ticks. That is 0.5 milliseconds, or 500 microseconds.
  4. fffffff. Seven f letters print all seven fraction digits: 0005000.

Example 3 — Compare with AddMilliseconds

Check that ticks and milliseconds agree and read the ticks in a day.

C#
using System;

class Program {
    static void Main() {
        DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
        Console.WriteLine(TimeSpan.TicksPerMillisecond);
        Console.WriteLine(TimeSpan.TicksPerDay);
        Console.WriteLine(dt.AddTicks(TimeSpan.TicksPerMillisecond * 250) == dt.AddMilliseconds(250));
    }
}

How It Works

  1. Per millisecond. There are 10,000 ticks in one millisecond.
  2. Per day. A day has 864,000,000,000 ticks (86,400 seconds times 10 million).
  3. Same instant. 250 ms as ticks lands on the same value as AddMilliseconds(250).
  4. Prints True. Both routes end at an identical tick count.

Frequently Asked Questions

A tick is 100 nanoseconds. There are 10,000,000 ticks in one second.
There are 864,000,000,000 ticks in a day (TimeSpan.TicksPerDay).
Use it for the finest step or when your data is already a tick count. Otherwise AddSeconds or AddDays reads better.
Yes. It moves the time earlier.
It returns the number of ticks since January 1, year 1 at 00:00:00.

Next: AddYears()

Add or subtract whole years; Feb 29 becomes Feb 28 in a non-leap year with System.DateTime.

AddYears() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful