Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put into hours : minutes

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
0
0
GB
I am producing a time sheet database which records total worked hours for the day and this is recorded in minutes.

I am trying to split this up into hours and minutes for the user so see so I'm using the following:

Int(ValueInMinutes / 60) & " : " & (ValueInMinutes Mod 60)

The problem is that if minutes ever becomes a minus (we work flexible times here) then the hours is always added by one... so, if the minutes was '-10' then the it reads '-0 : -10' or '-65' reads '-2 : -5'

Does anybody have any suggestions about how I can improve this code?

Many thanks...

 
Sorry but does anyone have any ideas please?

I'm kinda stuck on my project until I can get over this hurdle ;o)

Cheers...
 
If this is in a Query then you could use an Iif function, assuming you require negative hours and minutes then this might work

WorkingHours: IIf([ValueInMinutes]<0,&quot;-&quot; & Int(([ValueInMinutes]*(-1))/60) & &quot; : &quot; & (([ValueInMinutes]*(-1)) Mod 60),Int([ValueInMinutes]/60) & &quot; : &quot; & ([ValueInMinutes] Mod 60))
 
I code it into the background of the form.. thakns for the help though ;o)

Are there any other suggestions? Thanks...
 
I code it into the background of the form.. thanks for the help though ;o)

Are there any other suggestions? Thanks...
 
Yep done it... not ideal but it works

If ValueInMinutes <0 Then

SetHours = Int(ValueInMinutes / 60) - 1
SetMinutes = Int(ValueInMinutes Mod 60)
Merged = SetHours & &quot; : &quot; & SetMinutes

Else
etc etc
End If
 
Create a module called modMinToTime and paset the following function

Function mintotime(myminute)
mintotime = myminute \ 60 & &quot;:&quot; & Format((Abs(myminute Mod 60)), &quot;00&quot;)
End Function

You can now call this function from your db. Simple use

mintotime(myminutes)

replacing my minutes with your reference.

Good Luck :-9
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top