Link to home
Start Free TrialLog in
Avatar of Stef Merlijn
Stef MerlijnFlag for Netherlands

asked on

How to calculate number of minutes between two DateTime in a query?

Hi,

In Delphi I can calculate the number of minutes between two dates by using the function:
MinutesBetweenEx(StartDateTime, EndDateTime);

Is there a way to do this within a query?
I'm using a MS Access database.

Regards,
Stef
SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Assuming MS Access has the function DATEDIFF

SELECT DateDiff( mi, <STARTDATE>, <ENDDATE>) AS MinutesBetween
hi, mike
looks like youre few seconds later:)
ziolko.
Avatar of wimmeyvaert
wimmeyvaert

I guess it should be :
SELECT DateDiff( "n", <STARTDATE>, <ENDDATE>) AS MinutesBetween

instead of

SELECT DateDiff( mi, <STARTDATE>, <ENDDATE>) AS MinutesBetween

Best regrads,

The Mayor
And use :

For Hours    : SELECT DateDiff( "h", <STARTDATE>, <ENDDATE>) AS HoursBetween
For Minutes : SELECT DateDiff( "n", <STARTDATE>, <ENDDATE>) AS MinutesBetween
For seconds : SELECT DateDiff( "s", <STARTDATE>, <ENDDATE>) AS SecondsBetween

See http://www.access-programmers.co.uk/forums/showthread.php?t=14680

Yeah looks like we posted seconds apart Ziolko   :o)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stef Merlijn

ASKER

Thank you both very much for the solution.
I never knew that you can use the "as"-value within the statement.

Regards,
Stef
Glad to be of some help.
And thanks for the points and the grade.

Best regards,

The Mayor.