tags:

views:

143

answers:

2

I want to subtract from a DateTime.

Example:

date1 = 13/01/2004 12:20:00
result = Subtract(date1-15);

Output:

13/01/2004 12:05:00

How do I do this?

+13  A: 

You may take a look at the AddMinutes method:

var result = date1.AddMinutes(-15);
Darin Dimitrov
+1 for a complete answer
Erup
Be aware that calling `DateTime.AddMinutes(-1)` on a value that has been initialised to DateTime.MinValue throws an exception. Just be careful!
Charlie Salts
+1  A: 

Use DateTime.Add(TimeSpan) with a negative value

Or DateTime.AddDays(), .AddMinutes(), etc

Chad