# Comparing two date values

**URL:** <https://forum.uipath.com/t/comparing-two-date-values/782576>\
**Category:** Studio\
**Tags:** reosurce-panel, question, studio, activities, excel, uiautomation\
**Created:** [November 28, 2024, 6:55am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576 "2024-11-28T06:55:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanda\_kishore](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nanda_kishore/32/190324_2.png) [@nanda\_kishore](https://forum.uipath.com/u/nanda_kishore)\
**Post date:** [November 28, 2024, 6:55am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/1 "2024-11-28T06:55:45Z")

</div>

Hi,

I have a situation of extracting one date value from excel and extracting one date value from Portal using get text.. Two date values are showing same in message box but when i compare in if as equal or contain it’s not getting true.. find the below image and provide solution..

 ![A screenshot of a "Ticket Data Warehouse" dashboard from Capgemini displaying various ticket management and time tracking details. (Captioned by AI)](https://global.discourse-cdn.com/uipath/original/4X/c/c/0/cc01618c833d0af79d5d12437b648f1b2c7b7716.jpeg)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/d/4/cd43658abb1efd7ff073e50b04b5da2113245446.jpeg)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/c/5/d/c5d000e407b16a3a7455af7f8b7601369bc7f1a5.jpeg)  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/3/f/0/3f02c5c1a2c1816d45ff3ab2da191b2757354f14.jpeg)

Regards,  
Kishore.

---

<div class="post-metadata">

**Author:** ![tazunnisa.badavide](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tazunnisa.badavide/32/419354_2.png) [@tazunnisa.badavide](https://forum.uipath.com/u/tazunnisa.badavide)\
**Post date:** [November 28, 2024, 6:59am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/2 "2024-11-28T06:59:53Z")

</div>

Verify if the data types are the same in both.

---

<div class="post-metadata">

**Author:** ![nanda\_kishore](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nanda_kishore/32/190324_2.png) [@nanda\_kishore](https://forum.uipath.com/u/nanda_kishore)\
**Post date:** [November 28, 2024, 7:01am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/3 "2024-11-28T07:01:09Z")

</div>

Both are in string type

---

<div class="post-metadata">

**Author:** ![tazunnisa.badavide](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tazunnisa.badavide/32/419354_2.png) [@tazunnisa.badavide](https://forum.uipath.com/u/tazunnisa.badavide)\
**Post date:** [November 28, 2024, 7:03am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/4 "2024-11-28T07:03:15Z")

</div>

also ensure there are no extra spaces

---

<div class="post-metadata">

**Author:** ![lrtetala](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@lrtetala](https://forum.uipath.com/u/lrtetala)\
**Post date:** [November 28, 2024, 7:09am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/5 "2024-11-28T07:09:13Z")

</div>

Hi @nanda_kishore

Can you try like below

```auto
If DateTime.ParseExact(excelDateValue.Trim(), "dd MMM ddd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-ddd") = DateTime.ParseExact(portalDateValue.Trim(), "dd MMM ddd", System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMM-ddd")
    ' Matched
Else
    ' Not matched

```

Regards,

---

<div class="post-metadata">

**Author:** ![Sanjay\_Bhat](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/sanjay_bhat/32/497227_2.png) [@Sanjay\_Bhat](https://forum.uipath.com/u/Sanjay_Bhat)\
**Post date:** [November 28, 2024, 7:11am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/6 "2024-11-28T07:11:23Z")

</div>

Hi  
Do this and then compare  
`DateVariable1=DateTime.Parse("07 Oct Mon").ToString("dd/MMM")`

Replace “07 Oct Mon” with the date variable(String type)

Try this!

---

<div class="post-metadata">

**Author:** ![ashokkarale](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashokkarale/32/474400_2.png) [@ashokkarale](https://forum.uipath.com/u/ashokkarale)\
**Post date:** [November 28, 2024, 7:41am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/7 "2024-11-28T07:41:41Z")

</div>

@nanda_kishore,

Comparing two dates in string format not a good practice.

You should be parsing the string format dates into datetime datatype and then compare.

---

<div class="post-metadata">

**Author:** ![AkshaySandhu](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/akshaysandhu/32/77316_2.png) [@AkshaySandhu](https://forum.uipath.com/u/AkshaySandhu)\
**Post date:** [November 28, 2024, 7:52am UTC](https://forum.uipath.com/t/comparing-two-date-values/782576/8 "2024-11-28T07:52:29Z")

</div>

hey  
it could be related to different type of space chars.  
Better approach would be to convert string to date then compare it like below:

`Log message = CDate("07 Oct Mon") = CDate("07 Oct Mon")`

in above example I used static string, replace it with your desired variables
