Reputation:
i want to get datetime for 2days before. i.e) how to subtract 2 days from datetime.now
Upvotes: 4
Views: 2918
Reputation: 12164
I think you are just looking for:
DateTime.Now.AddDays(-2);
Upvotes: 27
Reputation: 20794
Yet another solution:
DateTime twoDays = DateTime.Now.Subtract(new TimeSpan(2,0,0,0));
Upvotes: 1
Reputation: 9891
or try:
DateTime.Now.Subtract(TimeSpan.FromDays(2));
Upvotes: 9