473,379 Members | 1,216 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,379 software developers and data experts.

Calculate difference in times in seconds

28
hi,

how do i calculate difference in time in seconds (00:09:05 - 00:09:00 = 300) where start time being a field and the difference in time is calculated in AHT field, ie last record minus previous record. this should be a continious excercise in ms access database table
Aug 17 '08 #1
7 12003
janders468
112 Expert 100+
I would check out the DateDiff function built in to access for example to calculate the above would be:
Expand|Select|Wrap|Line Numbers
  1. DateDiff("s", #09:05:00#, #09:00:00#)
  2.  
This will return -300 (absolute value is 300 seconds), the 's' tells it to do the return result in seconds, there are other parameters you can give but the help files explain much better than I can so I'll leave that to you. Also, I changed the problem slightly because the value you gave appears to be a difference of 5 seconds, whereas it looked like you were trying to get 5 minutes (300 seconds). Hope that helps.
Aug 18 '08 #2
missinglinq
3,532 Expert 2GB
To calculate lapsed time you would use

DateDiff("s",StartTime, EndTime).

You don't do it backwards

DateDiff("s", #09:05:00#, #09:00:00#)

and then take the absolute value! You'd simply use

DateDiff("s", #:09:00:00#, #09:05:00#)

The OP has, indeed, posted times of 9 minutes and 9 minutes and 5 seconds after midnight, which from his posted expected results is incorrect. But this is only the beggining of the problems with this post.

how do i calculate difference in time in seconds... where start time being a field and the difference in time is calculated in AHT field, ie last record minus previous record. this should be a continious excercise in ms access database table
orajat, you're simply going to have to do a much better job of explaining what you're trying to do here, in order for us to give you any real help. This explanation simply makes no sense as written. You have to remember that you can see your database but we cannot. We're completely dependent on your explanation.

In particular you need to clarify "last record minus previous record. this should be a continious excercise in ms access database table"

You need to help us if you want us to help you!

Welcome to Bytes!

Linq ;0)>
Aug 18 '08 #3
orajat
28
this is what i'm trying to do...the start time will auto populate from system time everytime a new row is added. when that happens, the aht field would calculate the difference in time....aht = starttime(2nd record) - starttime(1st record), then 3rd record - 2nd record and so on an so forth.

StartTime Aht
3:28:52 AM 330
3:34:22 AM 108
3:36:10 AM 232
3:40:02 AM 0
Aug 18 '08 #4
NeoPa
32,556 Expert Mod 16PB
If you are talking of records sequenced in order of the StartTime field (note there is no date element in the consideration - almost certain to throw this in a mess) then you will need to process through a sorted recordset using either DAO or ADODB (Basic DAO recordset loop using two recordsets may help with that).

Processing through the records in code is necessary as standard SQL routines have no concept of order within records.
Aug 20 '08 #5
janders468
112 Expert 100+
Thanks Linq,

I was posting in the event that you were interested in finding the absolute value for the duration of tasks you complete before you begin. Thanks for the correction, foolish mistake on my part.
Aug 20 '08 #6
youmike
69
Don't forget that in Date/Time fields Access handles date as the integer portion of the field and time of day as the decimal fraction. Therefore, if you take the difference beteewn two date/time fields and multiply this by 86400 - the number of seconds in a day - you will get the number of seconds in the date/time difference.
Aug 21 '08 #7
hjozinovic
167 100+
In order to 'join' the previous record time with current record time try looking here .
We discussed similar thread and I believe you could find it helpfull.
Aug 21 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates:...
8
by: DraguVaso | last post by:
Hi, I'm new to WebServices, and I'm doing some tests (with a small VB.NET-application) to know the performance-difference between a WebService and the 'normal'-way of getting data (just...
11
by: Laery | last post by:
Hi, I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date. I know I could use an...
3
by: Eric Rechter | last post by:
Hi, What's the easiest way in php to calculate the hour and minutes (HH:MM) between 2 times? (unix timestamps) thanks in advance! Eric
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
9
by: howzit | last post by:
I have a set date in my MySQL database that records when a Sales Lead is established and I echo that date as $row_rsLead; I need to be able to calculate how many days that lead has existed....
19
by: xianwei | last post by:
#include <stdio.h> #include <stdlib.h> #include <time.h> int main ( int argc, char *argv ) { long i = 10000000L; clock_t start, end; double duration;
4
by: lenygold via DBMonster.com | last post by:
I found this example in MYSQL: create table events ( id integer not null primary key , datetime_start datetime not null , datetime_end datetime not null ); insert into events values ( 1,...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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.