Question : How to get the YEAR portion from a DATETIME variable?

hi,

I have the following variables.

dim ndate as DateTime
dim ndatestr as string = "03/24/10"

DateTime.TryParse("ndatestr", ndate)

I need to get the YEAR from ndate and increment by 1 year.
And I need to always display March 1st with the year calculated from above in the format MM/DD/YY.
Is there a date function to do this above?
Thanks for any help.

Answer : How to get the YEAR portion from a DATETIME variable?

The others have answered you main question, but for the remainder of your requirement:

1:
2:
3:
4:
5:
6:
Dim ndate As DateTime
Dim ndatestr As String = "03/24/10"

If DateTime.TryParse("ndatestr", ndate) Then
    ndate = new DateTime(ndate.Year + 1, 3, 1)
End If
Random Solutions  
 
programming4us programming4us