user1027620
user1027620

Reputation: 2785

C# Date Manipulation to filter users

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

Answers (1)

Darin Dimitrov
Darin Dimitrov

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

Related Questions