473,799 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DATE COMPARISON How to compare records on two tables

3 New Member
Hello everyone, I´m starting to learn Access , SQL and a bit of VB.

My problem is the following: I have two tables, one of them contains the records for missing points on a GPS system (called the "missing" table) ... the second table, contains all the available points on GPS (called the "complete" table). I will put an example

Table: Missing

Field1:Hour
----------------
10:04
10:09

Table2: GPS

Field1:X Field2:Y Field3:Hour
----------- ------------ -----------------
10 20 10:01
11 23 10:02
12 18 10:03
14 20 10:05
13 20 10:06
14 22 10:07
16 21 10:11


What I need to do is the following: go to each record on the "Missing" table and look for the record that is closer so to assign the values of Field1 and Field 2. to it. For example, lets look at the firs registry on table "missing" which is 10:04 .... on the GPS table i can found that there are two records that are close to 10:04, 10:03 and 10:05 ... so i want to average the values of the fields X and Y, and asign that average to a new fields on the missing tables as "AvgX" and "Avg"Y ... on this case it would turn out with the values of 13 for AvgX (average of 12 and 14) and 19 for AvgY (average of 18 and 20), like this:


Table: Missing

Field1:Hour Field2:AvgX Field3:AvgY
---------------- ----------------- -----------------
10:04 13 19



I was hoping to find a way to do it with sql queries, but i cant seem to find a way to compare between records, or the only choice is VB? in the case its VB, could somebody please guide me on same basic code i can apply?

thanks in advance,
Jul 11 '07 #1
5 2392
kepston
97 Recognized Expert New Member
While I work on this, I have a couple of questions.

Will you accept fractions?
e.g. your second missing example is 10:09 producing X=15, Y=21.5

What result do you want if the missing time is not exactly half way between known points?
e.g. what values for 10:10? The same as 10:09, or higher, if higher, by 'distance' covered (linear interpolation).
Jul 12 '07 #2
lucianone41
3 New Member
While I work on this, I have a couple of questions.

Will you accept fractions?
e.g. your second missing example is 10:09 producing X=15, Y=21.5

What result do you want if the missing time is not exactly half way between known points?
e.g. what values for 10:10? The same as 10:09, or higher, if higher, by 'distance' covered (linear interpolation).

1. Thanks for your help!


2. regard your questions:

a. I accept fractions, there is no problem with that, in fact the data i put as an example was an integer approximation, in fact almost all the coordinates are numbers with fractions, but I put it on integer to simplify it.

b. If the missing time is not exactly half way between known points , then what it would be great is to have the most proximate point to the missing point. Originally i thought of linear interpolation as you said it .... for example:

if the missing point is 10:10 and I have as choices 10:07 and 10:11 ... I think there could be two choices: picking 10:11 because its nearer or making a linear interpolation using 10:07 and 10:11 ..... I believe the first choice is better because for this problem, one minute is really a huge difference, so taking an interpolation might produce a point pretty far away from an approximate point .... but either solution is good, so if you want to try any of this versions is excellent for me ....

again thanks, i appreciate your interest in helping me
Jul 12 '07 #3
kepston
97 Recognized Expert New Member
if the missing point is 10:10 and I have as choices 10:07 and 10:11 ... I think there could be two choices: picking 10:11 because its nearer or making a linear interpolation using 10:07 and 10:11 ..... I believe the first choice is better because for this problem, one minute is really a huge difference, so taking an interpolation might produce a point pretty far away from an approximate point .... but either solution is good, so if you want to try any of this versions is excellent for me ....
I think you have misunderstood interpolation.
If we look at finding position at 10:10, then position at 10:11 would be better than at 10:07, using nearest known position.
Position at 10:11 would also be better than the average, which in this case would be position at 10:09. i.e. 2 minutes away from known!
Interpolation works out how far between start and end, required point is, and calculates for that position.
10:11-10:07 =4
10:10-10:07 =3
so we calculate position 3/4 of distance from position at 10:07 to 10:11.

(This will be accurate in a two dimensional space at constant speed and direction)
Jul 12 '07 #4
lucianone41
3 New Member
I think you have misunderstood interpolation.
If we look at finding position at 10:10, then position at 10:11 would be better than at 10:07, using nearest known position.
Position at 10:11 would also be better than the average, which in this case would be position at 10:09. i.e. 2 minutes away from known!
Interpolation works out how far between start and end, required point is, and calculates for that position.
10:11-10:07 =4
10:10-10:07 =3
so we calculate position 3/4 of distance from position at 10:07 to 10:11.

(This will be accurate in a two dimensional space at constant speed and direction)
I see, i was misunderstandig interpolation, i thought it was more like a weighted average ....
anyway, i think what it would fit best would be choosing , as you said, the nearest point from the missing one, also because i least i can guarantee that the point really exists.
Jul 12 '07 #5
kepston
97 Recognized Expert New Member
I see, i was misunderstandig interpolation, i thought it was more like a weighted average ....
anyway, i think what it would fit best would be choosing , as you said, the nearest point from the missing one, also because i least i can guarantee that the point really exists.
Choosing an actual point makes sense.
In which case, do you want the point before, or after, or both when midway between known points?

qryNearestTime:
Expand|Select|Wrap|Line Numbers
  1. SELECT Missing.Hour AS MHour, Min(Abs([GPS].[Hour]-[mHour])) AS NearestTimeDiff,
  2. [mhour]-[nearestTimeDiff] AS Bef, [mhour]+[nearestTimeDiff] AS Aft
  3. FROM GPS, Missing
  4. GROUP BY Missing.Hour;
  5.  
qryNearestPoint :
Expand|Select|Wrap|Line Numbers
  1. SELECT [qryNearestTime].[MHour], [GPS].[Hour], [GPS].[X], [GPS].[Y]
  2. FROM qryNearestTime INNER JOIN GPS ON ([qryNearestTime].[Aft]=[GPS].[Hour]) 
  3. Or ([qryNearestTime].[Bef]=[GPS].[Hour]);
  4.  
qryNearestPoint will currently show both before and after when equidistant
Jul 13 '07 #6

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

Similar topics

4
5129
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows for each record, each row accounts for a different type of outcome I'm having trouble with MySQL date comparison. I'm looking for some kind of query that will compare the all date column and only give me the latest date. Then once I have it, ...
2
10215
by: Scott Knapp | last post by:
Good Day - I have a form which sets the current date, as follows: <script type="text/javascript"> xx=new Date() dd=xx.getDate() mm=xx.getMonth()+1 yy=xx.getYear() mmddyy=mm+"/"+dd+"/"+yy document.write(mmddyy)
3
14614
by: andrew | last post by:
Hi: I am already using TreeMap to massage records in my export file such that each record has a unique key combination ( LastName + FirstName + Member Key) . Thus I am sorting the records by the unique key. I also have a Date String Field in my record ( ie "30-Apr-2005" ). I want to create a unique key combination of ( LastName + FirstName + Member Key + Date). Can you please tell me what are the steps I need to do to sort the Date
8
3656
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as text fields. Each date for example 10/31/03 or October 31st 2003 is stored as 10/31/A3 in the system. My reasoning for this is because they couldn't solve their Y2K problem or this is their solution to it. All dates prior to 2000 are stored...
4
3765
by: blini | last post by:
Helo.... How I can convert string "26/03/2006 15:51" for a date? I need to convert and to compare if "09/06/2006 14:20" is lesser or equal that the current date. Everything in Javascript.
2
3042
by: sparks | last post by:
I am trying to find valid records in a table but I must compare a date field to a date stored in the table I can see where this is wrong (ok I guess its not text) "= """ & Me.date & """" so how do you format for a date comparison of a date field in a table and compared to a text box with a date format?
7
1820
by: matt | last post by:
hello, i have been given a challenging project at my org. i work on an inventory management web application -- keeping tracking of parts assigned to projects. in the past, i built an in-house ASP.NET reporting system. just your standard stuff -- user clicks on a report, the page executes a pre-defined SQL query, a dataset is formed and bound to a data repeater. that works well for us. and using some nifty CSS, my reports look good on...
5
1782
by: Addy Smith | last post by:
I have 2 tables with different versions in access. Both are same but the latest version obviously has some new records and some deleted records from the previous version. How would I compare the new table with the old one? I have a common field called MFI_ID having the value AT00100, AT10000 etc, in both the tables. I need to put the query and find out the new records in the new table as well as deleted records from the old table. The comparison...
2
2746
by: Louverril | last post by:
I have a problem I just can't get any sort of query findfirst or the sql below to correctly compare a value in a table with a supplied value. I created a very simple situation to try and figure part of it out. I have one table with three fields ID, myname and Birthday. There are three records in there one has a birthday of 01/04/2008 (todays date - this is NOT an April Fool!) The Birthday field is formated as a date and just takes the...
0
10495
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
10269
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...
0
10032
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
9085
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
6811
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
5469
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
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
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
3
2942
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.