473,786 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.T ime
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 1971
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

TblSurfConditio n
SurfConditionID
BuoyDataID
SurfConditionDa te
SurfConditionTi me
SurfConditionRa ting
WaveHeight

Make BuoyDataID In TblBuoyData, TideDataID in TblTideData and
SurfConditionID in TblSurfConditio n 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 TblSurfConditio n.

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******@pcdata sheet.com


"tdes42" <ti*******@goog lemail.comwrote in message
news:11******** **************@ n2g2000hse.goog legroups.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.T ime
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******@pcdata sheet.com


"tdes42" <ti*******@goog lemail.comwrote in message
news:11******** *************@5 7g2000hsv.googl egroups.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
2516
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 cartTemp where convert(varchar(4000),cartdetails) in (a.prodcode)) as counter from Products a where isOffer = 0 order by prodcode") do until RSMain.EOF
7
1685
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 was happening and just don't get it yet. Here's the starting query (reduced to simple prefixes): ----INITIAL-----
2
3357
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. Next, I want to get an insight in how the various items change over time. For that, I compare the results of one month with the results of another month. The form in which I want this is a cross-tab-query with one month as a row-header and another...
2
4675
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 tables, I'll just list a few, as the links are the same for all tables. These tables are: tblPermitMain tblApplicant tblContractor tblEngineer
7
4161
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; Basically I want to create a report that includes both system name and serial number. I'm new to this and none of the JOIn documentation was clear to me.
9
33707
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 tables here Table1 ID TIMESTAMP
21
3226
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 (i.e. the get_hash function) is borrowed from various snippets I found on the net. Thee free function could probably need some love. I have been thinking about having a second linked list of all entries so that the cost of freeing is in proportion to...
52
6356
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 variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
5
2741
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 they directed. Another table (People) keeps the names of the people. Everybody will have a unique ID. I have created a query like below to show the name and production year of the movie, the director name and the genre of the movie. Genres are also...
0
10363
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
10164
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
9961
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
8989
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, and deploymentwithout 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
6745
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
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
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.