Dim d1 As Date = Date.Parse("2005-11-25")
Dim d2 As Date = Date.Parse("2006-11-26")
Dim strDay As String = d1.Subtract(d2).ToString
相差天数出来,要怎么转年就自己来算了。
Dim fromDate As DateTime = New DateTime(2000, 1, 12)
Dim toDate As DateTime = New DateTime(2006, 1, 11)
Dim year As Integer
year = toDate.Year - fromDate.Year
If toDate.Month < fromDate.Month Then
year = year - 1
ElseIf toDate.Month = fromDate.Month Then
If toDate.Day < fromDate.Day Then
year = year - 1
End If
End If
MessageBox.Show(year.ToString)