Search code examples
c#asp.netdatetimerazor

How do I get the previous year in Razor syntax?


I'm working on some templates to an ASP.NET MVC 3 application, only thing I have access to are the .cshtml template files. I really know nothing about .NET so I'm just trying to piece together somethings. In one of my templates i need to output the previous year.

I know I can get the current year with @DateTime.Now.Year but I can't find any info on how to get the previous year.


Solution

  • @DateTime.Now.AddYears(-1).Year;