one endtime was derived from a date/time Format (like YYYYMMDD hh:mm:ss). I made a dozen of different formatting but didnot suceed (every Option I choosed, the TextBox showed the correct timeformat - and i only Need timeformat).
I got a hint, when I changed the Format to num and was very much surprised that it gave me a huge number (something 42000) which should be the date. So even if I formatted to time(myfield,'hh:mm') it still kept the old Format?
So I used the fract function and it works as desired
I then made use of the proposal of Gysbert and used rangemin instead of if ..
I know that when formatting on Surface, it still keeps the old Format, but did not thought that in script it's the same behaviour.