# Calculating Difference Between Date - DateDiff Error

**URL:** <https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175>\
**Category:** Help\
**Tags:** question, data-manipulation, activities\
**Created:** [November 14, 2019, 9:52pm UTC](https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175 "2019-11-14T21:52:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PJoEY](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@PJoEY](https://forum.uipath.com/u/PJoEY)\
**Post date:** [November 14, 2019, 9:52pm UTC](https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175/1 "2019-11-14T21:52:06Z")

</div>

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?**

---

<div class="post-metadata">

**Author:** ![rachrahul2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rachrahul2/32/21459_2.png) [@rachrahul2](https://forum.uipath.com/u/rachrahul2)\
**Post date:** [November 14, 2019, 10:09pm UTC](https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175/2 "2019-11-14T22:09:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PJoEY](https://avatars.discourse-cdn.com/v4/letter/p/e56c9b/32.png) [@PJoEY](https://forum.uipath.com/u/PJoEY)\
**Post date:** [November 15, 2019, 3:11pm UTC](https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175/3 "2019-11-15T15:11:56Z")

</div>

Thanks @rachrahul2, that did the trick!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [November 18, 2019, 3:12pm UTC](https://forum.uipath.com/t/calculating-difference-between-date-datediff-error/168175/4 "2019-11-18T15:12:07Z")

</div>

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