VBA/Excel/Access/Word/Date Functions/Year
Use year function to get the year
<source lang="vb"> Sub AgeCalc2() " variable declaration Dim FullName$ Dim DateOfBirth As Date Dim age% " assign values to variables FullName$ = "John Smith" DateOfBirth = #1/3/1967# " calculate age age% = Year(Now()) - Year(DateOfBirth) " print results to the Immediate window MsgBox FullName$ & "is" & age% & " years old."
End Sub
</source>
Year(Date)
<source lang="vb">
Sub Main8()
Debug.Print "Today"s date is: " & Date Debug.Print "The year is: " & Year(Date)
End Sub
</source>