Random time expression

Hi everyone,

I am wondering if someone can help me please. I am trying to come up with an expression to give me a random HH:MM:SS time in between two times. Such as a random time between 09:30:45 and 16:40:55. I have used the RANDBETWEEN() function, but I can only get random times to the hour, and not random minutes and seconds also. Ive looked on the forum for an anwser but am struggling to find it.

Thank you for your time.

James.

1 Like

AppSheet doesn’t have a built-in function to generate random times to the second, but you can absolutely simulate this using a combination of RANDBETWEEN() and TIME() math.

1 Like

The easiest way is to construct an expression that assembles the random time in 3 parts:

An expression something like

RANDBETWEEN(HOUR([Time1]), HOUR([Time2])) & ":" & 
RANDBETWEEN(MINUTE([Time1]), MINUTE([Time2])) & ":" &
RANDBETWEEN(SECOND([Time1]), SECOND([Time2]))

I hope this helps!

2 Likes

Thank you very much @WillowMobileSys your expression worked perfectly and has helped me immensley, your a pro!! Thank you also @PauloExpert !

Many thanks,

James