Not able to get correct results of time comparison

0
I am trying to save the string value depending on the value of time attribute. If the time is between 6:30am to 3:15 pm then the value will be A, else if time range is between 3:15pm and 11:59pm then result valu should be B. I am able to get desired results. can anyone help.
asked
1 answers
2

I suspect this is not working because you are not specifying a date in the time comparison. If you don't set it then it will use the current date, but your MainData/Timestamp may be using a different date.

 

You can change how to generate the comparison date by using the Timestamp, trimming this to just the date, and then using that date string along with the time to compare against.

 

For example, to get 6:30am on the same day as the timestamp.

 

parseDateTime(formatDateTime(trimToDays($MainData/Timestamp), 'yyyy-MM-dd') + ' 06:30:00', 'yyyy-MM-dd HH:mm:ss')

 

https://docs.mendix.com/refguide7/trim-to-date/#5-trimtodaysutc

 

I hope this helps.

 

answered