need your help with access query

i have a table Data and i am using query Query 1
Name
InspectorName      InsDate               Time
User1                      5/1/2015      00:05
User1                      5/1/2015      00:05
User1                      5/1/2015      00:15
User1                      5/1/2015      02:10
User1                      5/1/2015      00:35
User1                      5/1/2015      01:40
User1                      5/1/2015      00:10
User1                      5/1/2015      00:35
User1                      5/1/2015      00:50
User1                     5/1/2015              00:25
User1                     5/1/2015              00:20
User1                     5/1/2015              00:35
User1                     5/1/2015              00:15
User1                     5/1/2015              00:10
what i need to calculate the total sum of the TIme, in this case it should be 8 hours 10 minutes

something needs to be converted to the right format, since i canot apply the sum to my Time
rfedorovAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

omgangIT ManagerCommented:
SELECT tblInspector.InspectorName, tblInspector.InsDate, Sum(DatePart("n",[InsTime])) AS TotalTime
FROM tblInspector
GROUP BY tblInspector.InspectorName, tblInspector.InsDate;


Use the DatePart function.  See example above.

OM Gang
0
rfedorovAuthor Commented:
thank you for your respond

i am having an error when i run the query
SELECT data.InspectorName, data.InsDate, sum(DatePart("n",[duration])
FROM data
group by InspectorName, InsDate
0
omgangIT ManagerCommented:
What error are you receiving?  Is [duration] column a date/time data type?  The DatePart function works on date/time data types only.
OM Gang
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rfedorovAuthor Commented:
you have a database attached, could you look at the database,
0
omgangIT ManagerCommented:
I don't see it.
0
rfedorovAuthor Commented:
Sorry :)
Test.accdb
0
hnasrCommented:
Try:

SELECT InspectorName      , Sum([Time]*24) AS sumOfTime
FROM Data
GROUP BY InspectorName ;

Open in new window

0
omgangIT ManagerCommented:
I am receiving no error with your sample database.

Query
SELECT data.InspectorName, data.InsDate, Sum(DatePart("n",[duration])) AS TotalTime
FROM data
GROUP BY data.InspectorName, data.InsDate;

Results
InspectorName      InsDate      TotalTime
User1      5/1/2015      310
User1      5/4/2015      0
User2      5/1/2015      446
User2      5/4/2015      0

OM Gang
0
rfedorovAuthor Commented:
yep, so far is great,
let me check something
0
hnasrCommented:
Applied my comment to your database.
attached.

SELECT data.InspectorName, Sum([duration]*24) AS Expr1
FROM data
GROUP BY data.InspectorName;

Open in new window


Result:
InspectorName      Expr1
User1              16.1666666666667
User2               18.4333333333333
Test-1.accdb
0
rfedorovAuthor Commented:
great, and finally, how to round 8.166666666666666666666 to 8:10???
0:05
0:15
0:35
0:20
0:25
0:50
0:35
0:10
0:05
1:40
0:10
0:35
2:10
0:15
0
Dale FyeCommented:
yourValue = 8.166666666666666666666

Format(8.16666666666, "h:nn:ss")
0
Gustav BrockCIOCommented:
You should not multiply by 24 but go straight:

SELECT InspectorName, Sum([duration]) AS SumotTime
FROM data
GROUP BY InspectorName;

Then apply the format h:nn to SumOfTime.

/gustav
0
rfedorovAuthor Commented:
none of your last comments are work for you, sorry
0
hnasrCommented:
Try this query: check the attached database.

SELECT Q.InspectorName, Format([expr1],"Short Time") AS theTime
FROM (SELECT data.InspectorName, Sum([duration]*24) AS Expr1 FROM data GROUP BY data.InspectorName)  AS Q;

Open in new window

Test-2.accdb
0
omgangIT ManagerCommented:
Or this one.
OM Gang

SELECT InspectorName, InsDate, [TotalDuration]\60 & Format([TotalDuration] Mod 60,"\:00") AS Dur
FROM (SELECT data.InspectorName, data.InsDate, Sum(DatePart("n",[duration])) AS TotalDuration
FROM data
GROUP BY data.InspectorName, data.InsDate);

Open in new window

0
aikimarkCommented:
This is the simplest form I can generate
SELECT InspectorName, InsDate, format(Sum([duration]),"hh:nn") AS TotalTime
FROM data
GROUP BY InspectorName, InsDate;

Open in new window

0
Gustav BrockCIOCommented:
> none of your last comments are work for you, sorry

It has to work and will do - except if your time field is not of data type Date. If it is Text, convert to Date:

SELECT InspectorName, Sum(CVDate([duration])) AS SumotTime
FROM data
GROUP BY InspectorName;

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rfedorovAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.