Reputation: 2785
How can I get the date for:
The reason for this is that I want to compare all user creation dates and check if the user registered within the last three weeks or last year.
In a C# ASP.NET Website.
Thanks in advance.
Upvotes: 0
Views: 206
Reputation: 1038730
Last three months
DateTime threeMonthsAgo = DateTime.Now.AddMonths(-3)
Last year
DateTime oneYearAgo = DateTime.Now.AddYears(-1)
Then you could compare the DateTime
instance with DateTime.Now
.
Upvotes: 2