UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> times for query criteria    
 
   
LizH
post Oct 7 2009, 10:48 AM
Post #1

New Member
Posts: 9



I cannot figure out how to write criteria to get a query to return all records with elapsed time between 1 second and 20 seconds.

I have a [start time] field and an [end time] field that I use to calculate elapsed time. What should I put in the query criteria to get all records with elapsed time between 00:00:01 and 00:20:00?
Go to the top of the page
 
+
orange999
post Oct 7 2009, 10:55 AM
Post #2

UtterAccess Guru
Posts: 630
From: Ottawa, Ontario, Canada



If your field [elapsed time] is recorded in seconds, then something like this should work

Select * from MyTable
Where
[elapsed time] between 1 and 20

What is your table structure?
Can you provide some sample data/results?
Go to the top of the page
 
+
theDBguy
post Oct 7 2009, 11:00 AM
Post #3

Access Wiki and Forums Moderator
Posts: 48,634
From: SoCal, USA



Hi LizH,

Welcome to Utter Access!

Looking at your sample data makes me wonder if you are storing your elapsed time as a date/time field. If so, you should change it to a Long data type and the suggestion already given should work.

Just my 2 cents...
Go to the top of the page
 
+
LizH
post Oct 7 2009, 11:29 AM
Post #4

New Member
Posts: 9



The start time and end time fields in my table are date/time. When I changed the date/time fields to long integer each time is now either a 1 or 0. I'm attaching a small sample table. Whatever help anyone can give I appreciate very much.
Attached File(s)
Attached File  Sample Time at Hospital.zip ( 48.71K ) Number of downloads: 1
 
Go to the top of the page
 
+
theDBguy
post Oct 7 2009, 11:58 AM
Post #5

Access Wiki and Forums Moderator
Posts: 48,634
From: SoCal, USA



Hi,

Check out the attached modified version and open up the query. Let us know if it's not what you're looking for.

Hope that helps...
Attached File(s)
Attached File  1890691-Sample Time at Hospital.zip ( 8.82K ) Number of downloads: 1
 
Go to the top of the page
 
+
big0
post Oct 7 2009, 12:43 PM
Post #6

UtterAccess Guru
Posts: 568



Try this one that I use.

big0
Attached File(s)
Attached File  test.zip ( 24.5K ) Number of downloads: 1
 
Go to the top of the page
 
+
vtd
post Oct 7 2009, 10:38 PM
Post #7

Retired Moderator
Posts: 19,667



>>...with elapsed time between 00:00:01 and 00:20:00?

The higher limit looks like 20 minutes to me???

If [StartTime] and [EndTime] are of DateTime data type, try:
CODE
SELECT T1.*

FROM [YourTable] As T1

WHERE DateDiff("s", [StartTime], [EndTime]) Between 1 And 20
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 19th June 2013 - 04:04 PM