Calculating Difference Between Date - DateDiff Error

I need to calculate the difference in days between two dates: 04-25-2019 and 06-23-2019

I have made the following “assign” activity:

DateDifference = DateDiff(DateInterval.Day, “04-25-2019”, “06-23-2019”)

  • “DateDifference” is an Int32 variable

I am getting the following Error:

Compiler error(s) encountered processing expression “DateDiff(DateInterval.Day, “04-25-2019”, “06-23-2019”)”.
Overload resolution failed because no accessible ‘DateDiff’ can be called with these arguments:

‘Public Function DateDiff(Interval As String, Date1 As Object, Date2 As Object, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long’: Option Strict On disallows implicit conversions from ‘Microsoft.VisualBasic.DateInterval’ to ‘String’.

‘Public Function DateDiff(Interval As Microsoft.VisualBasic.DateInterval, Date1 As Date, Date2 As Date, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long’: Option Strict On disallows implicit conversions from ‘String’ to ‘Date’.

‘Public Function DateDiff(Interval As Microsoft.VisualBasic.DateInterval, Date1 As Date, Date2 As Date, [DayOfWeek As Microsoft.VisualBasic.FirstDayOfWeek = FirstDayOfWeek.Sunday], [WeekOfYear As Microsoft.VisualBasic.FirstWeekOfYear = FirstWeekOfYear.Jan1]) As Long’: Option Strict On disallows implicit conversions from ‘String’ to ‘Date’.

Is there something that I am missing that is causing this error?

Hey,
Try this:
DateDifference = DateDiff(DateInterval.Day, Convert.todatetime(“04-25-2019”), Convert.todatetime(“06-23-2019”))
Also change DateDifference variable to Int64

1 Like

Thanks @rachrahul2, that did the trick!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.