# DateDiff(Inteverval.Month)

**URL:** <https://forum.uipath.com/t/datediff-inteverval-month/195834>\
**Category:** Academy Feedback\
**Tags:** question, studio\
**Created:** [February 20, 2020, 12:06pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834 "2020-02-20T12:06:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcelino](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marcelino/32/265262_2.png) [@Marcelino](https://forum.uipath.com/u/Marcelino)\
**Post date:** [February 20, 2020, 12:06pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/1 "2020-02-20T12:06:02Z")

</div>

Converted date:  
DateTime.ParseExact(in\_TransactionItem(“DateTime.String”).ToString,“dd-MM-yyyy”,NL\_Formaat)

Assign  
DateVariable2 = DateTime.ParseExact(in\_TransactionItem(“DateTime.String”).ToString,“dd-MM-yyyy”,NL\_Formaat).

Now I want to calclulate de difference in months between  
DateTime.now and DateTimeVariable2.

DateDiff(DateInterval.Month, DateTime.now, DateTimeVariable2)  
The result must have been 4 months  
I got 0 months.

Can anybody help me to solve this.

Thanks

---

<div class="post-metadata">

**Author:** ![GBK](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gbk/32/142274_2.png) [@GBK](https://forum.uipath.com/u/GBK)\
**Post date:** [February 20, 2020, 12:13pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/2 "2020-02-20T12:13:33Z")

</div>

> [@Marcelino](#):
>
> ParseExact

can you try to log these 2 variables (DateVariable2 / DateTime.now) and share the results…

---

<div class="post-metadata">

**Author:** ![karthick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/karthick/32/176690_2.png) [@karthick](https://forum.uipath.com/u/karthick)\
**Post date:** [February 20, 2020, 12:32pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/3 "2020-02-20T12:32:31Z")

</div>

DateDiff(DateInterval.Month, “Date1”,“Date2”) will definitely works

Have you converted both the values which you gonna manipulate to Date format?

---

<div class="post-metadata">

**Author:** ![Marcelino](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marcelino/32/265262_2.png) [@Marcelino](https://forum.uipath.com/u/Marcelino)\
**Post date:** [February 20, 2020, 1:59pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/4 "2020-02-20T13:59:24Z")

</div>

Sorry it didn’t help.

Nevertheless thanks for your help

---

<div class="post-metadata">

**Author:** ![Marcelino](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/marcelino/32/265262_2.png) [@Marcelino](https://forum.uipath.com/u/Marcelino)\
**Post date:** [February 20, 2020, 2:09pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/5 "2020-02-20T14:09:58Z")

</div>

ParseExact because convert to Datetime didn’t work.

Debug:

- Now gives the value 20-02-2020 15:03:12
- DateimeVariable2 gives the value 30-10-2019 00:00:00

I also tried to firstly convert Now to string and afterwards DateTime.ParseExact to get equal values.  
That didn’t work neither.

---

<div class="post-metadata">

**Author:** ![karthick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/karthick/32/176690_2.png) [@karthick](https://forum.uipath.com/u/karthick)\
**Post date:** [February 20, 2020, 2:11pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/6 "2020-02-20T14:11:44Z")

</div>

instead of convert Now to string use convert.ToDateTime(“String”).ToShortDateString

in your case i think Short date will help you

---

<div class="post-metadata">

**Author:** ![bcorrea](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/bcorrea/32/103778_2.png) [@bcorrea](https://forum.uipath.com/u/bcorrea)\
**Post date:** [February 20, 2020, 2:17pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/7 "2020-02-20T14:17:26Z")

</div>

> [@Marcelino](#):
>
> 20-02-2020

actually the result would be -4 not 4, and you certainly have a variable problem there, if it is 0 as result then you are maybe passing the same date in both variables or dates closer than a month…

---

<div class="post-metadata">

**Author:** ![UiJack](https://avatars.discourse-cdn.com/v4/letter/u/47e85d/32.png) [@UiJack](https://forum.uipath.com/u/UiJack)\
**Post date:** [February 20, 2020, 2:34pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/8 "2020-02-20T14:34:03Z")

</div>

Try with only DateTime.Parse(DateVariable) without providing the format as “dd-MM-yyyy”. It should work.

---

<div class="post-metadata">

**Author:** ![bcorrea](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/bcorrea/32/103778_2.png) [@bcorrea](https://forum.uipath.com/u/bcorrea)\
**Post date:** [February 20, 2020, 2:35pm UTC](https://forum.uipath.com/t/datediff-inteverval-month/195834/9 "2020-02-20T14:35:26Z")

</div>

then he will have an parse error as he does have a string with a different format…
