Almost there on time button

  • Thread starter Thread starter DaveB
  • Start date Start date
D

DaveB

I'm getting a lot closer to making it work! The only
problem now is when I click on Command94 it only gives me
the hours, but not the minutes. Command 92 is at 7:22pm
and Command93 is at 9:35pm but it shows in
TotalTimetoBill 2:00 instead of 2:08.

Option Compare Database

Private Sub Command91_Click()
Me!DateTime1stContact = now()
End Sub

Private Sub Command92_Click()
StartDateTime = Date + Time()
End Sub
Private Sub Command93_Click()
Me!CompletionDateTime = now()
End Sub

Private Sub Command94_Click()
Me.TotalTimetoBill = DateDiff("h", Me!StartDateTime, Me!
CompletionDateTime)
End Sub
 
Command 92 is at 7:22pm
and Command93 is at 9:35pm but it shows in
TotalTimetoBill 2:00 instead of 2:08.
...
Private Sub Command94_Click()
Me.TotalTimetoBill = DateDiff("h", Me!StartDateTime, Me!
CompletionDateTime)
End Sub

It's showing integer hours because that's what you're asking for: the
"h" argument to DateDiff calculates integer hours.

If you want integer minutes, use "n" (for miNutes - "m" is Months).
You can cast this into hh:nn format using an expression like


DateDiff("h", Me!StartDateTime, Me!CompletionDateTime) &
Format(DateDiff("n", Me!StartDateTime, Me!CompletionDateTime) MOD 60,
":00")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Almost there on time buttons again 1
buttons again & again & again..... 1
more buttons 1
Using a Botton to calculate time 2
hh:mm:ss on a timer 2
To hide UserForm command buttons 4
On Time Bug? 14
Time Format 6

Back
Top