473,402 Members | 2,055 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,402 software developers and data experts.

calculating the interval between two times in an Access query

Hi,

I have two times held as 'Short Time' in a date/time field in Access. I tried to use a DateDiff function in a query to calcualte the interval between these two times but it just returns a #Error.

Can anyone tell me how I can calculate the difference between these two times?

thanks
Lucie
Nov 21 '08 #1
3 9152
ADezii
8,834 Expert 8TB
To calculate the difference in Minutes between Time1 and Time2, and to also allow for the possibility of Time1 being prior to Midnight and Time2 post Midnight, and to place these values into a Calculated Field named [Time Diff]:
Expand|Select|Wrap|Line Numbers
  1. Time Diff: IIf(DateDiff("n",[Time1],[Time2])>0,DateDiff("n",[Time1],[Time2]),DateDiff("n",[Time1],[Time2])+1440)
Nov 21 '08 #2
That works a treat - thanks very much. What is the +1440 doing?
Nov 24 '08 #3
ADezii
8,834 Expert 8TB
The +1440 figures in the pre-midnight/post-midnight differential and adjusts, for example:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print DateDiff("n", #23:00 PM#,#04:00 AM#)
  2. 'produces ==> -1140 (19 hours)
Adding the +1440 to -1140 produces ==> 300 (5 hours) as in:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print DateDiff("n", #23:00 PM#,#04:00 AM#) + 1440 ==> 300
Nov 24 '08 #4

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

Similar topics

13
by: | last post by:
I have an Access database used to track donor pledges. In it, there is a table that contains three fields for each donor: Gift_Amount, Gift_Per_Year, and Matching_Gift_Ratio. The following...
1
by: Roland | last post by:
Hi, I have written a Windows Service with a Timer (System). The Interval is set to 60000 (60 seconds) for testing. In the Timer1_Elapsed event I execute a task. In this case I have to read a...
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
5
by: jonm4102 | last post by:
I'm trying to calculate the median of some numerical data. The data can only be found in a query (henceforth query 1) field I previously made, and I would prefer to calculate the median in a new...
8
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
3
by: jbosrock | last post by:
Hi to all, Please bear with me as I am newly experienced in basic Access 2003 only. I don't know Visual Basic or macros at all but am attempting to learn on my own. Explanation: Our fleet...
9
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by...
6
by: Adam1331 | last post by:
I am currently setting up a database for work that will operate as a timesheet. I have set up multiple tables, queries, forms and reports to help this process run smoothly. The issue that has...
1
by: aneinander | last post by:
I'm beginner and getting following error message, please help. The table contains transaction date, account number, branch, etc. And need to show previous transaction date or next transaction date...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.