Reputation: 295
I need to retrieve the current system date, not the actual date, using C# then subtract 3 months to get the previous 3 months using a loop. I thought you can just do:
DateTime currMonth = DateTime.Now.AddMonths(-3);
I was under the impression that DateTime.Now actually gave you the current system date, but according to the people who tested my code said it isn't getting the date.
Any insight or resources would be great!
Upvotes: 1
Views: 642
Reputation: 1503140
DateTime.Now
gives you the local system date/time, so:
It sounds like that's what you're after. It's not clear what you mean by "it isn't getting the date" but it looks correct to me, assuming that both of the above are what you want. To make it clearer that you want just the date, I'd suggest using DateTime.Today
though, which is equivalent to DateTime.Now.Date
.
Upvotes: 8