473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Convert Elapsed Time to Seconds

I need to be able to enter an elapsed time into a text
field. This time then needs to be converted into seconds
and stored in a field in some table.

The user will enter a time (format is h:minutes:seconds)
as such:

0:15:34 (0 hours, 15 minutes, 34 seconds -> 934 seconds total)

or as another example:

1:02:10 (1 hour, 2 minutes, 10 seconds -> 3730 seconds total)

Can someone please walk me through this? I imagine this is
VBA related (an Event Procedure), but I'm not sure of the
code or what 'Event' type to out this under for the given
text field.

Thanks.
Nov 12 '05 #1
3 28995
lucky for you, Access has 3 functions to assist your needs, and they
can be used in queries or in VB under forms to calculate a control to
a value that will update the desired table field.

These fuctions are hour(), minute(), and second(). Each one takes a
date/time OR a string time format, i.e. (like your user's will enter):
"03:45:23".

Then, all you need to do is run these three functions on that field to
achieve your result: hour(<dateORtextField>) * 3600 +
minute(<sameField>) * 60 + second(<sameField>).

That's it.
-Paul T.

fr*******@yahoo.com (fred14214) wrote in message news:<90**************************@posting.google. com>...
I need to be able to enter an elapsed time into a text
field. This time then needs to be converted into seconds
and stored in a field in some table.

The user will enter a time (format is h:minutes:seconds)
as such:

0:15:34 (0 hours, 15 minutes, 34 seconds -> 934 seconds total)

or as another example:

1:02:10 (1 hour, 2 minutes, 10 seconds -> 3730 seconds total)

Can someone please walk me through this? I imagine this is
VBA related (an Event Procedure), but I'm not sure of the
code or what 'Event' type to out this under for the given
text field.

Thanks.

Nov 12 '05 #2
SELECT tblTimes.ID, tblTimes.TextTime, CDate([TextTime]) AS TestTime,
DateDiff("s",Int(CDate([TextTime])),CDate([TextTime])) AS TestDiff
FROM tblTimes;

Create a numeric field in your table and set its type to long.

Then create an update query to fix all the values for you.

UPDATE MyTable
SET MyElapsedTimeField =
DateDiff("s",Int(CDate([TextTime])),CDate([TextTime]));

BTW, storing derived values usually isn't a good idea. I would base a
query on another query until I got what I wanted... much more
flexible.
Nov 12 '05 #3
Thank you for your time. I have another question.

I am basing a new query on an existing query. In the existing query is a
field of seconds. In the new query, I would like to get the average of
the 'field of seconds' from the old query. I can accomplish this by
using the Group By -> Avg function. This works, but it gives the answers
in seconds. How can I get the new query to display (in the query itself,
not a form) hours:minutes:seconds?

Thank you again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NotGiven | last post by:
Below is a good elapsed time function I found. However, I'd like to return total seconds instead of broken down into days, hours, minutes & seconds. In other words, I want "125" instead of "2...
6
by: Thomas Bartkus | last post by:
MySQL Version 4.0.20 on a Linux server. How does one get the elapsed time between (2) DateTime values? I need the answer to the nearest minute. Is upgrading to Ver 5 with its more robust...
20
by: Jean Johnson | last post by:
Hello - I have a start and end time that is written using the following: time.strftime("%b %d %Y %H:%M:%S") How do I calculate the elapsed time? JJ
0
by: Anurag | last post by:
Hi, ENV: DB2 ESE 8.2.3 DPF (11 nodes) on AIX 5.x ==== SCENARIO / SETUP ======== ====== (1) I needed to find out CPU Time (User / System) of SQL queries for benchmark testing. (2) I setup...
3
by: Bill Nguyen | last post by:
I need to display elapsed time for a process in VB.NET in secods. What's the routine to do this? Thanks Bill
1
by: Bill | last post by:
I have a large number of records that have an elapsed time in seconds for each one that I was to have a total time spent. I can sum them up with query easily enough but I need to be able to display...
12
by: Spitfire | last post by:
I've a requirement to find the elapsed time between two function calls. I need to find the time elapsed accurate to 1 millisecond. The problem I'm facing right now is that, I'm using the 'time()'...
0
by: Gabriel Genellina | last post by:
En Fri, 02 May 2008 16:13:41 -0300, Simon Pickles <sipickles@googlemail.comescribió: Two options: a) You can construct a datetime object with that info, using...
4
yarbrough40
by: yarbrough40 | last post by:
Can anyone help me to display a Decimal (or double) to elapsed time :mm:ss (hours:minutes:seconds)using vb.net? example: if you were to type "1.34666666666667" into a cell in Excel then choose...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.