-
Does anyone know of a reason I should use the VB function DatePart() as opposed to using Year() or Month() if I want to extract the year or the month from a date. Is one maybe going to go away in a future release of VB? It just seems odd to have two fuctions that do the same thing.
-
<?>
try this:
Private Sub Form_Load()
Dim TheDate As Date ' Declare variables.
Dim Msg
TheDate = Date
Msg = "Year: " & DatePart("y", TheDate)
MsgBox Msg
Dim MyDate, MyYear
MyDate = Date ' Assign a date.
MyYear = Year(MyDate) ' MyYear contains 1969.
MsgBox MyYear
End Sub