Displaying time correctly

MarionD

Registered User.
Local time
Today, 18:58
Joined
Oct 10, 2000
Messages
425
Hi all,
I know this is an age old question but I just can't get it right.

I have to display -0,029171 as time 00:00

I use this formula in an unbound field on the form
=([zuvielstd]*1440\60) & ":" & Format(Abs([zuvielstd])*1440 Mod 60;"00").

It sems to work fine unless the first part not a whole number.
Using this formula the above number displays as 0:42 instead of -0:42 mins.

if the number is -0,148611 for eg. it displays correctly as -3:34
Thanks for any help here!:banghead:
 
I think, you need to handle the signage separately from the rest of the expression.
Code:
Public Function NumberToTime(ByVal number As Double) As String
    NumberToTime = IIf(number < 0, "-", "") & (Abs(number) * 1440 \ 60) & ":" & Format(Abs(number) * 1440 Mod 60, "00")
End Function
Of course you can extract the expression from the function and use it on its own.
 
Oh wow! Thank you so much! Easy when you know how. Works great!

Marion
 

Users who are viewing this thread

Back
Top Bottom