Skip to main content

Good day,

 

I need to compare two dates and set the outcome of a process within a smartform on submit.  Both dates are being read via a SmartObject (from SQL).  I have checked the data type in SQL and they are both the same.  I have tried various comparison operators and I cannot get the dates to compare properly.

 

For testing purposes I have even tried to compare dates in the conditional formatting styles and within the form rules without success.

 

Any ideas as to how I can proceed here?

 

We are using K2 4.6.7

Should be quite straight forward, I wouldve thought. How I have done it basically use the "advanced condition" rule and in thre just use the out of the box operater such as greater than  equal to etc etc. You may have issues I gess, if the two dates are in different formats for example. What I woud suggest is to create a data label and then write both dates into those data latels. Then in the properties for those data labels set it to the same date types format. and then do the comparison between those data labels, just to rule out any issues with mismatch of date formats.

 

If all fails then you canpass both dates into the workflow and the after the start rule have a code event where you can use c# to manipulate the dates into the same formats. Then compare the dates using the c# library. Then have a datafield called something like "pathdecision" in the process that ou can write to for example. if date a is greater than date b srite "followpathA". and in the line rules coming out of the code event activity, yo can do if "pathdecision" = followpatha do this.

 

hope this helps


What controls are you loading the dates into to compare?


 


If your loading the controls into a Date Picker control, it will tack on a Zule time format (which adds date/time even if you don't see it).  I would probably output your test controls to a data label to see what exactly is being compared.


 


If it is the date picker controls, I would probably output them anyway to a data label and do a compare on the lables.


 


Let me know if you have more info after doing some testing...I can try some compares on this end to play around with it.


 


David


I created a test view with 2 calendar controls and was able to compare them with an expression tied to a data label.


 


When I modified the controls to match the datas, the label switched to true...otherwise it showed false.  Let me know if this condition doesn't work with loading the data from SQL.


13986i39D2B2C105B44F13.png


Hi all


 


There are multiple solutions for this, but the quickest and easiest ones that i can think of would be the following.


Please have a look at this screenshot thoroughly as there are three views each comparing two dates in the same way but the output is different.


I only used a Expression on the Text Box that would display the comparison results as boolean(True/False).


Expression is "MatchessCalDate1, CalDate2]".


"Matches" is a regular expression and the CalDates I used is pulled from the smartobject. Note - When you do not supply the dates on the view itself then you have to tell the view how to get the from the smartobject by using a unique identifier (Example: ID).


14647i67BF0DBAB0D1561F.png


Kind Regards


Raymond


 


Reply