Date & Time Format in Ms Access Queries

S

sbmoor

Hi,

Previously I asked for help on the below request. I got reply from
someone which I really appreciate, unfortunately it seems not working.
Can anyone verify that funtion and could tell me exactly how i gonna
use it. Thank you for the support.

This is my previous request:
------------------------------------------------------------
I am a beginner to MSAccess. Recently I imported a huge file contains
data about Telco providers outage timings as follows: Following are the
three columns from excel.

"Problem Start Time ", "Problem End Time" and "Duration", duration is
the difference between the first two columns.
It was all ok when these fields are at excel as I have to display them
in

d:hh:mm format which is days:hours:minutes.

Pls. take a look at the exact format below.

Start Time End Time Duration
m/d/yyyy h:mm - m/d/yyyy h:mm = d:hh:mm
5/23/2006 16:19 - 5/25/2006 11:21 = 1:19:02
Pls. help me to find a way to display in the format of d:hh:mm.

Thanks in advance
Moor
---------------------------------------------------------------------

The reply i received with a function which is not working for me
is..... below:

-------------------------------------------------
Here is a function
that will return the duration in dd:hh:mm format:
Function ShowDuration (dtmStart as Date, dtmEnd as Date) as String
Dim lngDur and Long
lngDur = DateDiff("n", dtmStart, dtmEnd)
ShowDuration = Format(lngDur\1440,"00:") & _
Format((lngDur -(lngDur\1440)*1440)\60,"00:") & _
Format((lngDur -(lngDur\1440)*1440) Mod 60,"00")
End Function
------------------------------------

I need to use them in query.

Thank you so much
Moor
 
D

Douglas J. Steele

That function should work fine. Unfortunately, there's a typo in it.

Dim lngDur and Long

should be

Dim lngDur As Long
 

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