Datatype for time

I want to import an Excel file that contains time in the format below.  I want to do calculations on time (like how many minutes),

00:05:36
00:04:19
00:02:42

Again, so I want to add this to access and be able to sum up and say, for example, that it was 3 hours or 25 minutes, etc...

I'm (1) not sure what data type and (2) how I may be able to sum up.

I attached a sample if it helps.
sample.xls
patriotpacerAsked:
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.

Jeffrey CoachmanMIS LiasonCommented:
To be clear, what is the *exact* result you want for the values displayed...
0
patriotpacerAuthor Commented:
>>All format types of Time in Access

Thank you


>>To be clear, what is the *exact* result you want for the values displayed...

Just be able sum them up would probably work.


60 MINUTES =

00:20:00
00:20:00
00:20:00
0
Jeffrey CoachmanMIS LiasonCommented:
1. Import the Excel File
2. Create a query like this:
SELECT Sum([YourMinutesField]) AS TotalMinutes
FROM YourTable;
3. Set the format property of this filed to: hh:nn:ss

This will give you:  0:12:37
...as the result for those numbers
(12 minutes, 37 seconds)
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Gustav BrockCIOCommented:
Don't let you confuse; it's not about the format, it's about the data type.

And the data type for date and/or time in Access is Date.

/gustav
0
Jeffrey CoachmanMIS LiasonCommented:
...or you can create an expression:
    DSum("YourMinutes","YourTable")

And use that as the controlsource for a textbox:
    =DSum("YourMinutes","YourTable")
...Then set the format property of this textbox to:  hh:nn:ss
0
Gustav BrockCIOCommented:
To sum time periods, just sum these.
If the total is within 24 hours, that's all.

If more then 24 hours, and you wish a display like 34:15, use a function like this:
Public Function FormatHourMinute( _
  ByVal datTime As Date, _
  Optional ByVal strSeparator As String = ":") _
  As String
  
' Returns count of days, hours and minutes of datTime
' converted to hours and minutes as a formatted string
' with an optional choice of time separator.
'
' Example:
'   datTime: #10:03# + #20:01#
'   returns: 30:04
'
' 2005-02-05. Cactus Data ApS, CPH.

  Dim strHour       As String
  Dim strMinute     As String
  Dim strHourMinute As String
  
  strHour = CStr(Fix(datTime) * 24 + Hour(datTime))
  ' Add leading zero to minute count when needed.
  strMinute = Right("0" & CStr(Minute(datTime)), 2)
  strHourMinute = strHour & strSeparator & strMinute
  
  FormatHourMinute = strHourMinute
  
End Function

Open in new window

/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
Jeffrey CoachmanMIS LiasonCommented:
patriotpacer,

<I'm (1) not sure what data type and (2) how I may be able to sum up.>

When you import your table to Access, ...Access should set the data-type as "Date\Time".
However, it might display an odd date as well.
You can cure this by setting the format property of the field to: hh:nn:ss

Jeff
0
patriotpacerAuthor Commented:
thanks.

I will review and test all the comments posted.  

I really appreciate the help.
0
patriotpacerAuthor Commented:
Thank you so much for all the help.

The function worked VERY well.
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
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.