Comparing time value (+/-) to other time values

rpswift

New member
Local time
Yesterday, 16:24
Joined
Oct 14, 2014
Messages
3
This likely is easy - but not for this newbie... Need a make table query (Access 2013) as follows:

I have a table named tbl_Samples.

tbl_Samples has relevant record fields SampleID and TimeCollected (this field contains only time-not date-and these two times would be during a 24-hour period [i.e., same calendar date])

I want to select a record where SampleID contains "-8" somewhere in the string. I do this using Criteria: Like("*-8*"). Got that bit right...

I then want to use the value of time collected associated with this sample ID record to identify a second sample ID record with a collection time exactly either 15 minutes earlier or 15 minutes later.

Thanks for any advice!
 
What data type have to you used to store timecollected ?
 
Date/Time, and the field contents are like "11:35:00 AM"
Thanks!
 
Access solutions
Use the function Timeserial, Timeserial(0,15,0) is 15 minutes

Use the date/time notation, #8:00:00# is 8 am, #0:15:00# is 15 minutes, you can actually use that to calculate with
#8:00:00# - #0:15:00# = #7:45:00#
#8:00:00# + #0:15:00# = #8:15:00#

Technical solution
A date or time is a double value... integers being days, decimals being the time part.

As a result, 8 am today is actually 41927.33333333333333
8 am without any date is 0.3333333333333
Adding 15 minutes then is 15 minutes of 60 minutes per hour of 24 hours per day aka 15 / 60 / 24
Thus
8:00:00 am + 15/60/24 = 8:15:00 am
8:00:00 am - 15/60/24 = 7:45:00 am
 

Users who are viewing this thread

Back
Top Bottom