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

join table based on Time comparison

I believe I am looking for some form of Join Query, but my
understanding of Access logic and my logic do not yet click entirely….

I have a table of ocean buoy data, taken every hour over many days
(hopefully a whole year if it doesn’t slow things down too much):
tblBuoy
Date Time Swell Direction Swell Period Swell
Height
5/6/2007 15:00 195
14.2 2.568
5/6/2007 16:00 196
14.0 2.671
etc.

And, tblTide (taken every 15 minutes, also for a whole year)
Date Time Tide Height
5/6/2007 15:00 3.452
5/6/2007 15:15 3.643
etc.

And, tblConditions (taken at somewhat random times throughout a day) –
Surf Conditions
Date Time Rating Wave Height
5/6/2007 15:02 Fair Waist High
5/6/2007 15:49 Poor to Fair Chest High
etc.

I would like to join the three tables, matching the Conditions to the
closest tide and swell information based on Date and Time.
My first solution just cuts the minutes off the tblConditions.Time
field, and takes Tide information every minute (which for a year of
data is I think far too large and far too precise).
I am right at the dangerous knowledge of Access, I can throw some code
from different places around and make it work… but don’t have really
any idea why it works I really appreciate any thoughts, suggestions,
answers to how this can be tackled, and apologize if this has been
handled somewhere else (I did search for an answer in several places).
Thank you :)
Tim

Jul 21 '07 #1
3 1948
To begin, you need to change the names of your Date and Time fields. "Date'
and "Time" are reserved words and should not be used for field names or
object names.

How about a different design of your tables ---
TblBuoyData
BuoyDataID
BuoyDataDate
BupyDataTime
SwellDirection
SwellPeriod
SwellHeight

TblTideData
TideDataID
BuoyDataID
TideDataDate
TideDataTime
TideHeight

TblSurfCondition
SurfConditionID
BuoyDataID
SurfConditionDate
SurfConditionTime
SurfConditionRating
WaveHeight

Make BuoyDataID In TblBuoyData, TideDataID in TblTideData and
SurfConditionID in TblSurfCondition autonember data type and Access will
automatically fill these fields when you revise your tables. For BuoyDataID
in TblTideData, create a query that includes TblTideData. Add a calculated
field to the query to combine TideData Date and TidedataTime into one field.
Create a query that includes TblBuoyData. Add a calculated field to the
query to combine TideData Date and TidedataTime into one field. Sort the
calculated field ascending. You now need code that loops through the records
in your TideData query, for each record finds the record in the BuoyData
query where the previous record has a date and time less than the date and
tine in the TideData query and the next record has a date and time more than
the date and tine in the TideData query then updates BuoyDataID in the
TideData query to the BuoyDataID in the record in the BuoyData query. Use
the same process for BuoyDataID in TblSurfCondition.

When the above is completed you will have all TideData records linked to a
BuoyData record and all SurfCondition records linked to a BuoyData record.
You will be able to build a form with two subforms where the main form
displays a BuoyData record, one subform dosplays TideData records related to
the BuoyData record and the other subform displays SurfCondition records
related to the BuoyData record.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com


"tdes42" <ti*******@googlemail.comwrote in message
news:11**********************@n2g2000hse.googlegro ups.com...
I believe I am looking for some form of Join Query, but my
understanding of Access logic and my logic do not yet click entirely..

I have a table of ocean buoy data, taken every hour over many days
(hopefully a whole year if it doesn't slow things down too much):
tblBuoy
Date Time Swell Direction Swell Period Swell
Height
5/6/2007 15:00 195
14.2 2.568
5/6/2007 16:00 196
14.0 2.671
etc.

And, tblTide (taken every 15 minutes, also for a whole year)
Date Time Tide Height
5/6/2007 15:00 3.452
5/6/2007 15:15 3.643
etc.

And, tblConditions (taken at somewhat random times throughout a day) -
Surf Conditions
Date Time Rating Wave Height
5/6/2007 15:02 Fair Waist High
5/6/2007 15:49 Poor to Fair Chest High
etc.

I would like to join the three tables, matching the Conditions to the
closest tide and swell information based on Date and Time.
My first solution just cuts the minutes off the tblConditions.Time
field, and takes Tide information every minute (which for a year of
data is I think far too large and far too precise).
I am right at the dangerous knowledge of Access, I can throw some code
from different places around and make it work. but don't have really
any idea why it works? I really appreciate any thoughts, suggestions,
answers to how this can be tackled, and apologize if this has been
handled somewhere else (I did search for an answer in several places).
Thank you :)
Tim
Jul 21 '07 #2
Wow!! :) Thank you Steve and Allen for the help, and so quick... I
will need a bit of time to sort through both answers.
I had originally separated the Date and Time fields, because data
entry had repeated Dates but different Times, and I wanted to shorten
the data entry time. But it sounds better if I find a way to combine
these, maybe after they are entered on the form.

If I understand your solutions, I eliminate all but the Tide Data on
the hour. To be a bit difficult (sorry :) ) I can achieve this
simply by asking the internet tide data source to produce data for
each hour... I was hoping to maintain a higher accuracy on the Tide
Data than the Buoy Data. Tides change faster. But it's probably best
to go down to the hour, implement your solutions. The more I think
about it, hourly tides are great!

OK... I have a feeling I'm not done asking questions, but now I have
some work to do implementing your solutions :)

Thanks so much,
Tim

Jul 21 '07 #3
<< I eliminate all but the Tide Data on the hour. >>

You don't need to do this! It's okay to have four points of Tide Data for
every Buoy Data.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
re******@pcdatasheet.com


"tdes42" <ti*******@googlemail.comwrote in message
news:11*********************@57g2000hsv.googlegrou ps.com...
Wow!! :) Thank you Steve and Allen for the help, and so quick... I
will need a bit of time to sort through both answers.
I had originally separated the Date and Time fields, because data
entry had repeated Dates but different Times, and I wanted to shorten
the data entry time. But it sounds better if I find a way to combine
these, maybe after they are entered on the form.

If I understand your solutions, I eliminate all but the Tide Data on
the hour. To be a bit difficult (sorry :) ) I can achieve this
simply by asking the internet tide data source to produce data for
each hour... I was hoping to maintain a higher accuracy on the Tide
Data than the Buoy Data. Tides change faster. But it's probably best
to go down to the hour, implement your solutions. The more I think
about it, hourly tides are great!

OK... I have a feeling I'm not done asking questions, but now I have
some work to do implementing your solutions :)

Thanks so much,
Tim

Jul 21 '07 #4

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

Similar topics

8
by: niceguy | last post by:
I'm trying to select records from two tables. the following code works for what i want to to: set RSMain = conn.execute ( "select top 20 product, prodcode, edition, ( select count(id) from...
7
by: Greg | last post by:
I'm a quantitative securities analyst working with Compustat data (company fiscal reports and pricing feeds). My coworker came across a problem that we fixed, but I'd like to understand 'why' it...
2
by: HS Hartkamp | last post by:
Hi all, I have a table with analysis-results for various months. An item can -for a particular month- have the result 'list1', 'list2' or 'list3' depending on the result of the analysis. ...
2
by: dskillingstad | last post by:
I would really appreciate someone's help on this, or at least point me in the right direction.... I'm working on a permit database that contains 12 tables, and rather than list all of the...
7
by: Shanimal | last post by:
I would like to know how to join 2 queries so that the results of these 2 queries show up in the same query: SELECT b.bios_serial_number FROM bios b: SELECT s.system_name FROM system s; ...
9
by: Mahesh S | last post by:
Hi I have to perform an update on a table. I am having problems figuring out how to join two tables as I need to check a value in a different table before performing the update. I have two...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
5
by: Dot Net Daddy | last post by:
Hello, I have set up a database for movies. In one table (Movies) I have movie names, and production years, and also genres. In another table (Directors), I keep the directors and the movies...
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?
0
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,...
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
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...
0
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...
0
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 projectplanning, coding, testing,...

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.