473,666 Members | 2,296 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with creating a duration field

Greetings,

I am trying to create a duration field in a query. I have a field with
a start time and a field with an end time. They are both in military
time, and are formatted as hours:minutes. I am trying to create a
duration field by subtracting the start time from the end time. This
is working.

However, some end times do not happen until the following day, and
this is screwing up the results. If the start time is 04:30 and the
end time is 04:40, the duration field is successfully populated with
"10" minutes. However, if the start time is 23:30 and the end time is
01:30 (the next day), instead of getting "120" in the field, I get a
"-1,320" (60 minutes x -22 hours). Is there some way to make Access
interpret the end time as always being after the start time so it will
know in these instances the end time is for the next day? Or do I have
to include the date in these time fields so Access knows to look at
the next day?

Thanks in advance to anyone who can help!

Dave
Nov 12 '05 #1
1 2236
How are you getting the duration value?

If you use the DateDiff function, you can get the number of seconds
between two Date-Time values.

DateDiff("s",#1 2/10/2003 11:55:50 PM#,#12/11/2003 1:03:50 AM#) = 4080

--

Danny J. Lesandrini
dl*********@hot mail.com
http://amazecreations.com
"Dave" <dh***@mmua.org > wrote in message news:ee******** *************** ***@posting.goo gle.com...
Greetings,

I am trying to create a duration field in a query. I have a field with
a start time and a field with an end time. They are both in military
time, and are formatted as hours:minutes. I am trying to create a
duration field by subtracting the start time from the end time. This
is working.

However, some end times do not happen until the following day, and
this is screwing up the results. If the start time is 04:30 and the
end time is 04:40, the duration field is successfully populated with
"10" minutes. However, if the start time is 23:30 and the end time is
01:30 (the next day), instead of getting "120" in the field, I get a
"-1,320" (60 minutes x -22 hours). Is there some way to make Access
interpret the end time as always being after the start time so it will
know in these instances the end time is for the next day? Or do I have
to include the date in these time fields so Access knows to look at
the next day?

Thanks in advance to anyone who can help!

Dave

Nov 12 '05 #2

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

Similar topics

2
3864
by: windos | last post by:
Dear all, I am a new in using Crystal Report. I'm trying to add this query in CR : SELECT
2
2877
by: Gunnar Vøyenli | last post by:
Hi Some days ago I posted a problem with a query. Thaks to Dave and John, I got a little closer to a solution. Their suggestion was a solution to my problem as I stated it, but the real problem is a bit more complicated, so I have to expand the original problem a bit. The query has to handle unknown number of departments, and a date interval. I want: 1) For each day, for each department: a list of (from at_work table) all
5
1696
by: angelasg | last post by:
I am working with employee schedules. Each schedule is comprised of segments (shift, lunch, break, training, etc.) that have rankings. Each record has the employee id, the date the shift starts, the start and end time of each segment, the duration,the segment type and its rank. The start and end times of the schedules can overlap, but the segment that has the higher rank takes precedence. As a simple example, an employee working 8a-5p...
4
5702
by: Stephen Young | last post by:
Hello Have a bit of a problem, im trying to get the total number of hours:minutes for all actions over the month in a query, have tried two methods to no luck... Duration This Month: Format(Sum(.-.),"hh:nn") displays the total hours but rolls over anything over 1 day and starts
8
6919
by: Xarky | last post by:
Hi, I am creating a program, and when it is executed it stores the time. Now at each second I will display the duration of the program execution. DateTime progExecuted = DateTime.Now; I started a thread that is to be used only for the timer. In the thread I have another object of type DateTime, that reads the time each second.
2
7228
by: pradeep.thekkottil | last post by:
I'm setting up an auction website using PHP and MySQL. There in the section where logged in members can put up new auction in a form, I want to run a form validation where I used if else statements to check the fileds filled. In the form page there are two radio buttons - fixed and auction - (only one can be chosen) and depend upon which one is chosen some text should be inserted in the text fields. For that I'm using a validation where...
20
7494
by: anthonyk | last post by:
Hi there, im hoping someone might be able to painlessly tell me what im incorrectly doing here/expecting. Im using Access 2007 I am creating a query to show ongoing tasks in a database. in the fields I have Start date (dd/mm/yyyy) Duration (months) Basically i want the query to calculate is if start date + Duration is greater than today...
6
2820
by: Jim Mandala | last post by:
Using MS Access 2003 with SQL Server 2005 as a backend: I am trying to automatically check for collisions in a table of appointments with an appointment currenlty being saved from the form "FormAppt". I do this by calculating an end time form the start time and duration. Then I have two queries. The first one, "QueryA", finds all the appointments that day for that staff person which start before the end time of the appointment currently...
1
5898
by: Constantine AI | last post by:
Here is the situation i am currently trying to update a sales order using PHP and javascript. When you click on the edit button it brings you a new site page with existing sales order details within. I am wanting the order lines to be within option boxes so they can modify the order if they wish. I created some javascript for the create sale site page which automatically assigned a price to a particular product once selected. Here is the code...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8866
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...
0
8638
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
7381
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
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
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
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.