# How to compare two dates?

**URL:** <https://forums.pega.com/t/how-to-compare-two-dates/1602>\
**Category:** User Experience\
**Tags:** user-experience, pega-platform\
**Created:** [July 23, 2021, 2:43pm UTC](https://forums.pega.com/t/how-to-compare-two-dates/1602 "2021-07-23T14:43:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChensuZ51](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@ChensuZ51](https://forums.pega.com/u/ChensuZ51)\
**Post date:** [July 23, 2021, 2:43pm UTC](https://forums.pega.com/t/how-to-compare-two-dates/1602/1 "2021-07-23T14:43:15Z")

</div>

Hi all, I am having an issue comparing two dates using @DateTime.CompareDates(DateA, DateB) function.

In the requirement, both DateA and DateB are from clipboard, but to simply the problem, I use a constant for DateB.

If I do @DateTime.CompareDates (20220101, 20190101), it will return true, which is good, but if I set my DateA (I named it “EffDate” to be 20300101, then compare them @DateTime.CompareDates(.EffDate, 20190101), it’s returning false.

 ![my activity says if DateA is after DateB, set .TestCompareDate to be true. Otherwise false.png](https://pega1.discourse-cdn.com/pega/original/2X/2/2971022314c0d76b1f6c35898d368d79519e0eea.png)

 ![detail about my When condition.png](https://pega1.discourse-cdn.com/pega/original/1X/712e3f56348ad854039f76ef51e4567a20fbbcbf.png) ![my tracer .jpg](https://pega1.discourse-cdn.com/pega/original/2X/e/e74cf1532ba6673e9c16baa6703e32009013078c.jpeg)

They both should return true but the second one returns false ☹

Could anybody help me figure this problem out? Much appreciated!

---

<div class="post-metadata">

**Author:** ![ChensuZ51](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@ChensuZ51](https://forums.pega.com/u/ChensuZ51)\
**Post date:** [July 23, 2021, 4:02pm UTC](https://forums.pega.com/t/how-to-compare-two-dates/1602/2 "2021-07-23T16:02:15Z")

</div>

@ChensuZ51

This problem is solved. I did not know I should put double quotation around the hardcoded date like this “20190101”
