473,657 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating date differences from a table?

Hello All,
I have been trying to create a query that extracts data from a table
and calculates the elapsed time between records. The table called
"Imported_table ". I need to be able to calculate the difference in
dates when the vin and labourop are the same and not show any other
records except for these and add a new field called days elapsed and
odom elapsed. Refer to rough sample data below. Anyhelp would be
greatly apreciated.

VIN LabourOP Date Odom
123 abcd 1/1/04 125
124 dddd 2/2/04 253
123 abcd 3/1/04 131

Nov 13 '05 #1
1 2033
create a query (qryMinDate) to find the minimum date by vin, labourOp
SELECT imported_table. vin, imported_table. labourOp,
Min(imported_ta ble.date) AS minDate, Min(imported_ta ble.odom) AS
minOdom
FROM imported_table
GROUP BY imported_table. vin, imported_table. labourOp;
then create a query (qryDateDiff) to find the difference
SELECT qryMinDate.vin, qryMinDate.labo urOp,
DateDiff("d",[minDate],[imported_table].[date]) AS dateDiff,
[imported_table].[odom]-[minOdom] AS odomDiff
FROM qryMinDate INNER JOIN imported_table ON (qryMinDate.vin =
imported_table. vin) AND (qryMinDate.lab ourOp =
imported_table. labourOp);
you should be able to paste these into queries to see how they work
I would rename the 'date' to something like 'readingDate' since 'date'
is a reserved word and makes life difficult

I would also question the need to create fields 'days elapsed' / 'odom
elapsed' when they can be derived from the query about... the trick in
database design is to not store calculated data

Nov 13 '05 #2

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

Similar topics

6
9046
by: Ralph Freshour | last post by:
What's a good way to calculate the number of days between two dates in the following format: 2003-07-15 2003-08-02 I've looked at the PHP date functions but I'm still a bit lost...
12
23751
by: Anthony Robinson | last post by:
Is anyone aware of a function (system or user defined) that will calculate business days? For instance: I have a column in as table called DATE. I want to be able to add five business days to that date and come up with a new date. Is that possible. Also, is there anyway that DB2 can be aware of holidays? Maybe load them onto the server in some type of reference file or something. I ask these questions because I'm working on a banking...
1
2504
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals. first, let me say that this is a really long post. i wasn't sure how much information/ background to provide, so i thought more was better than less. i tried to delineate certain areas so that it would be easy to peruse my posting and find...
1
4301
by: Tony Williams | last post by:
I have a table with two fields, txtvalue (a number field) and txtmonth ( a date/time field). I want to create a report that shows the difference in value between the value in txtvalue in one value of txtmonth and the value of txtvalue in another value of txtmonth and the percentage increase . For example if I have the value 1000 in 30/03/03 and the value 1100 in 30/03/04 How do I calculate the difference as 100 and the increase as 10%. I...
5
3519
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 to 1800 stores of a national home improvement chain store. Every week I electronicaly receive an excel spreadsheet "inventory report" with 19,800 rows or records, which I import into my tblSalesData table. The table now has 10 weeks of data or...
1
1851
by: b.beeching | last post by:
Not sure if my subject is entirely accurate but here goes. I need to calculate the date difference between a date A and a date B... however date B relies entily on date A. EG: i have an advert in a paper (The Daily Telegraph say), now i need to know the next and previos dates that this occured. I can do this very easily for a one time calculations, however i need to do this for many 000's of rows.
8
3998
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 10:00:00 AM 12:00:00 PM 120
1
1972
by: rodneyeid | last post by:
Hi, I have an attendance machine which saves records in an Access Database in the following format : UserID DATE/TIME Checktype where if checktype is 0 then its check in and if it is 1 then it check out I need to calculate number of hours for each userID /day. I.e UserID =1 DATE/Time= 11/12/2007 12:36 P.M CheckType=0 UserID = 1 DATE/Time= 11/12/2007 17:36 P.M CheckType=1 i am counting the day as being from 12:00 am till...
25
3195
by: Blaize | last post by:
Hi, I'm having an issue trying to calculate time. Its okay if the value does not exceed 24 hours otherwise I get a date and hours listed. For example, I have a loop which looks through a table and adds up the time spent. Dim TempCount As Date Dim DEVCount As Date Do TempCount = rst!wtime
0
8399
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
8312
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
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8504
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
7337
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
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
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
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.