OCLOperators AddTicks
.AddTicks returns a new DateTime moved forward by a number of ticks. A tick is 100 nanoseconds, and 10,000,000 ticks make one second. Use a negative number to move backward and get an earlier time.
Syntax
aDateTime.AddTicks(numberOfTicks)
Returns
DateTime
Examples
Forward 10,000,000 ticks (1 second):
DateTime.Parse('2026-11-23 14:30:00').AddTicks(10000000).ToString('yyyy-MM-dd HH:mm:ss.fff')
Result: 2026-11-23 14:30:01.000
Back 10,000,000 ticks (negative value):
DateTime.Parse('2026-11-23 14:30:00').AddTicks(-10000000).ToString('yyyy-MM-dd HH:mm:ss.fff')
Result: 2026-11-23 14:29:59.000
Notes
- The argument must be a whole number.
.AddTicksis the most precise way to move a DateTime. You can pair it with Ticks on a TimeSpan:aDate.AddTicks(aTimeSpan.Ticks)gives the same result asaDate.Add(aTimeSpan).- See Ticks for a conversion table.
