Almost there on time button

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
 
J

John Vinson

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

Top