VB.NET "argument not specified for datevalue of Public Function day(datevalue as date) as integer"

Trying to find the difference between two dates in years and months. Works fine without the if statement. Get the error message “arugment not specified for datevalue of Public Function day(datevalue as date) as integer” for all lines below the if statement. Please help :slight_smile:

Dim date0 As Date = Now
Dim date1 As Date = Date.Parse(iJsonObjOrig(“AdditionalData”)(“People”)(0)(“Addresses”)(0)(“DateEnteredProperty”).ToString)
Dim month As Long = DateDiff(DateInterval.Month, date1, date0)
If date0.Month < date1.Month Then
Dim year As Long = DateDiff(DateInterval.Year, date1, date0) - 1
Else
Dim year As Long = DateDiff(DateInterval.Year, date1, date0)
End If

oJsonObjDest.Add(New JProperty(“address01HistoryYears”, year))
oJsonObjDest.Add(New JProperty(“address01HistoryMonths”, month - (12 * year)))

initialize variables without IF-else block and use a clear syntax

Dim date0 As Date 
date0 = Now
Dim date1 As Date
date1 = DateAdd("d",1,date0)
Dim month As Long 
month = DateDiff(DateInterval.Month, date1, date0)

Dim year As Long 
If date0.Month < date1.Month Then
	year = DateDiff(DateInterval.Year, date1, date0) - 1
Else
	year = DateDiff(DateInterval.Year, date1, date0)
End If

@PhiaConnolly13
have a look below for some acrobatics you maybe can use