Convert a time value HH:mm to seconds

0
So In an EventHandler microflow I need to compare 2 values, both expresed in seconds.  So, before compare them, I need to transform a value of Time, expresed in hours and minutes, “HH:mm” that can go from 00:01 to 24:00  (1 second and 86400 beign this last value, the total amount of seconds in 1 day) how can I easily transform this time in HH:mm to seconds? is it a function for this?   Get the total amount of seconds contained in the time value 
asked
2 answers
0

Hi,

If I get your idea correctly, you can do like this:

 

  1. Create a string variable $myDate that takes a random date. For instance ‘03/30/2023’
  2. Create a datetime variable $date1 with expression: parseDateTime($myDate, ‘MM/dd/yyyy’)
  3. Create another datetime variable $date2 with expression: parseDateTime($myDate + ‘ ‘ + $yourHHmm, ‘MM/dd/yyyy hh:mm’)
  4. Create a decimal variable $seconds with expression: secondsBetween($date1, $date2)

$yourHHmm is the value you want to convert to seconds.

answered
0

Use the seconds between function: https://docs.mendix.com/refguide7/between-date-function-calls/

Create a date time object with the right time and then you can count between this value and the start of the day. So for instance

secondsBetween(dateTime($dateToCheck), dateTime([%BeginOfCurrentDayUTC%])).
You do have to make sure that both are on the same day. So either create a variable date time of the current day and add the hours and minutes and then do the count.

 

Regards,

Ronald

 

answered