Comparing String Dates in particular format

0
Hi, I am storing some dates in database in a particular format. The format that i am using for storing the date is formatDateTime(date,'dd.MMM.YYYY')  so this date is getting stored as a string type in database. Now i want to compare this date with the current date. I am first converting the current date in this formatDateTime([%CurrentDateTime%],'dd.MMM.YYYY') and then trying to compare it. So if I am comparing directly like ( 21.Oct.2020 < 24.Nov.2020) then it is returning false but actually it should return true as 24 Nov is greater than 21 Oct. So if anyone can help me in comparing this type of string dates in Mendix as I am not storing the date in database as date type but i am storing it as string type in database as when we format the date it automatically gets converted to string. So what can be correct way to compare string dates of above format in microflow. I am using Mendix version 8.12.1.
asked
2 answers
2

You cannot lexicographically compare Dates and expect that you will get the same results if you would compare real dates. For example 21.Oct.2020 < 24.Apr.2020 will return true, as 21 is lexicographically smaller then 24. 


For your example “21.Oct.2020 < 24.Nov.2020” returns true for me in Mx 8.12.3, which is correct. 

 

answered
0

But why storing a date as string and then trying to compare is mathematical?

answered