To obtain the number of hours and minutes among two dates

F

Frank Dulk

I need to know the no. of hours and minutes among two dates. I made like
this a consultation:
Expr2:
Int(((CData([Data_fim]+[Hora_Fim])-CData([Data_inicio]+[hora_inicio])))*24)
But it didn't work. Until it comes back me the number of hours, but I need
that also come back me the minutes:
For instance:
Data_inicio:10/11/2003
Hora_inicio: 15:10

Data_fim: 10/11/2003
Hora_fim: 18:30

Wanted answer: 3,20 (3 hour and 20 minutes)
Given answer: 3

Or be it ignores the minutes.
 
J

John Spencer (MVP)

Try using the datediff function with combined date and time. I do not know the
value of the parameter for minutes - in english it is the letter "N". The two
formulas are:

Hours:
DateDiff("n",CData([Data_inicio]+[hora_inicio]),CData([Data_fim]+[Hora_Fim])) \
60

Minutes:
DateDiff("n",CData([Data_inicio]+[hora_inicio]),CData([Data_fim]+[Hora_Fim]))
Mod 60

You can then combine these to get hours and minutes, by concatenating them
together.

Formula for Hours & "," & Formula for Minutes
 

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