Xpath and Date comparision

0
Hello, I am using a custom java action that accepts entity name and xpath expression and does a retrieve.  The reason am using java action is since my xpath is genearted dynamically based on seach criteria entered in a search screen.  The solution works fine, but i am stuck with date comparision,  I am building xpath  like ‘ date column >  $date variable’, but I am don’t know how to convert string to date in xpath.  formatDateTimeUTC doesn’t work in xpath.     if someone can provide some pointer it will be helpful.    '//ProjectFoundation.Project[  CrossChargeable= ' + '''' +  'Y' + '''' + ' and (ClosedDate > ' + 'formatDateTimeUTC(' +   '''' + toString($WeekendDate) + '''' + ',' + '''' + 'MM/dd/yy, HH:mm am' + '''' + ')'  + ' or ClosedDate = empty) ' + ' and contains(ProjectFoundation.Project_ProjectCustomers/ProjectFoundation.ProjectCustomers/CustomerName, ''JAC'') '+ ']'          
asked
3 answers
0

The Xpath you are building gets triggered in Mendix-retieve? Use the functions that are available in Xpath: https://docs.mendix.com/refguide/xpath-constraint-functions. These will allow you to build the string you need. 

FormatDateTimeUTC returns a string. You are comparing the string to ClosedDate. Is ClosedDate also a string? If so, then take into account that when comparing date strings using > they need to be formatted yyyyMMddhhMMss to get the desired result.

answered
0

Hi Rajesh,

You can use SimpleDate Format which converts the string to date format in Java

eg:

  1. import java.text.SimpleDateFormat;
  2. import java.util.Date;  
  3. String sDate1="31/12/1998";  
  4. Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(sDate1);  

 

Hope this helps!

answered
0

Thanks much!

answered