Comparing the Dates


Please guide me out to compare the dates ?

For Example , I have to check whether the given date( 10/15/2010) presented between (10/01/2010) to ( 10/01/2011).

Please let me know to this get it done ?


**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.


Keep up to date on this post and subscribe to comments

October 15, 2010 - 9:44am

You may have to write a function to achieve this.
Example somthing like

if ( startdate.equals("00000000") || enddate.equals("00000000") )
return 0;
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyyMMdd");
java.util.Date date1 = null;
java.util.Date date2 = null;
date1 = dateFormat.parse(startdate);
date2 = dateFormat.parse(enddate);
}catch(Exception e){
oLog.infoForced("parsing exception DateDifference, invalid date formats, please use yyyyMMdd formats");
long diff = date2.getTime() - date1.getTime();

if (diff < 0){
diff = diff *-1;

return (int)(diff/(1000L*60L*60L*24L));
You can call this two times and check the result, but the inputs dates should be in the format yyyymmdd, or else you can format the date using simpledateformat class.
Try to search how to compare dates using Java you will find very good examples like the one above.
Good Luck

October 20, 2010 - 3:48pm


Thanks for all your response .

finally I got the solution. We can use the function IsDateBetweenDates(startDate,CurrentDate,Enddate,tools).

Usage : "startDate" <= "CurrentDate "<= "EndDate" else return False.


October 20, 2010 - 3:59pm

OK that will work. but its easier than that, if your two dates are truly values of two properties, both of type Date or both of type DateTime.

The internal representation of a date is 8 characters in the form YYYYMMDD, so 10/15/2010 is "20101015".

So you can compare two dates with just a string comparison
Date1 < Date2.


February 15, 2013 - 5:03am

Hi Gopi


Am not able to find  IsDateBetweenDates(startDate,CurrentDate,Enddate,tools) function in expression builder and anywhere in pega. Can u help me?



October 1, 2015 - 1:29am

Hi I got the same requirement, For this I did as mentioned below.

I have 3 dates EffectiveDate and StartDate and EndDate. So First I compared with @DateTimeDifference(Param.Effectivedate, Param.TempStartDate, D) and @DateTimeDifference(Param.TempEndDate, Param.Effectivedate, D)

When I compared the dates I will get differences between the dates.  So based on the difference we can make the conditions.