ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

RemoveTicks

Legible way to remove ticks from a datetime. Use instead Add negative days

Source

public static DateTime RemoveTicks(this DateTime value, long quantity)
{
     return value.AddTicks(quantity * -1);
}

Example

public static void Main()
{
     Console.WriteLine(DateTime.Today.RemoveTicks(864000000000));
     //Will Write 7/19/2018 12:00:00 AM
}

Author: Rafael Tadeu Bezerra Faria

Submitted on: 20 jul 2018

Language: C#

Type: DateTime

Views: 4971