davemackey davemackey - 7 months ago 40
Vb.net Question

VB.NET Get Only Year from Date

I'm pulling into a variable a datetime value. Now, I want to post this value back to my database, but I need it to be only the year digits. How do I get VB.NET to trim the month, day, and time off and just return the four character year (e.g. 2011)?

Answer

Date.Today.Year is what you're looking for, or for an existing date, just someDateVariable.Year