473,774 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:secon ds)
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 29035
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(<dateORtex tField>) * 3600 +
minute(<sameFie ld>) * 60 + second(<sameFie ld>).

That's it.
-Paul T.

fr*******@yahoo .com (fred14214) wrote in message news:<90******* *************** ****@posting.go ogle.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:secon ds)
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.TextTi me, CDate([TextTime]) AS TestTime,
DateDiff("s",In t(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 MyElapsedTimeFi eld =
DateDiff("s",In t(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:s econds?

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
12345
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 minutes 5 seconds". Any ideas? Thanks very much! function calcElapsedTime($time) { // calculate elapsed time (in seconds!) $diff = time()-$time;
6
24810
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 date/time functions the only solution? You can directly subtract 2 DateTime values and a long integer results. What is that number?
20
12604
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
1817
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 an EVENT MONITOR WHERE AUTH_ID = 'ANURAG' (write to table).
3
10285
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
5254
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 this in a easier to read format. I was able to do that for individual records by multiplying the elapsed time by (1/24/60/60) and using hh:nn:ss for the format but can't for the total because it is greater than 24 hours. I need to be able to do...
12
16370
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()' function call for the purpose and regardless of how many time I invoke the function within my program, I get the same output!!! For better clarity consider the code snippet below. ... start_time = time(NULL);
0
1511
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 datetime.datetime.fromtimestamp() (note that the MySQLdb module already returns datetime objects for timestamp columns in MySQL). If you substract two datetime objects, you get a timedelta object, which stores info as whole days, seconds (fraction of day) and microseconds...
4
15323
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 Custom Format :mm:ss The result is an elapsed time of "32:19:12". Using the OADate function only runs on a 24 hour clock so this does not work for longer durations unfortunately...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.