get year only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm reading an excel file using C#, and it has a date column formatted like:
MM/DD/YYYY, I have code that is getting me the year but its also returning me
12:00 so it looks like this:

2002 12:00 AM, how can I only get the year and not the time as well?

the field looks like this:
1/1/2000 I only want the year
 
For any object of type DateTime cannot you use the Year.ToString() method e.g.
DateTime.Now.Year.ToString ();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top