Anonymous asked in Computers & InternetProgramming & Design · 1 decade ago

C# Date Question?

How do I get the year so i can display via an ASPX page?

I currently have:

DateTime vDate = DateTime.Now;

and vDate displays just fine, but I only want to show the year, not the month, day and time.

1 Answer

  • 1 decade ago
    Favorite Answer

    The DateTime class has a property called Year that returns an integer so you could do

    int vYear = vDate.Year;


    int vYear = DateTime.Now.Year;

Still have questions? Get your answers by asking now.