|
-
Aug 20th, 2003, 08:22 AM
#1
Thread Starter
New Member
Access Time difference
I want to create a query that selects a date and time entry in a database compares them and if the difference is greater than 8 hours display the details.
is this possible?? i've managed this with days using DATEDIFF but i have no idea how to do this with time i tried:
SELECT * FROM tblProblem WHERE DATEDIFF(""h"",[LastUpdateTime],TIME())=8 And Status<8 And Priority=2"
This is as an sql string in VB6 it doesnt give any kind of error message but doesn work either, i also tried changing the 8 to "08:00:00" but that had the same effect.
This query needs to work on an Access 2000 database.
Any help would be MUCH appreciated
Thanx
chetz
-
Aug 20th, 2003, 08:37 AM
#2
One thing I see is that you are doing an "equal" comparison, so you will only get results if the time difference is EXACTLY 8 hours (no minutes, no seconds). I would first try a >= comparison.
"It's cold gin time again ..."
Check out my website here.
-
Aug 20th, 2003, 08:46 AM
#3
Thread Starter
New Member
tried >=8 but that did the same thing...returns nothing
any other suggestions??
i've been working on this for the past few days with no success
In the famous words of Vanilla Ice "word to ya mutha"
-
Aug 20th, 2003, 08:57 AM
#4
Try using NOW() instead of TIME(). It looks like the TIME function has a date component which uses the "origin" date of 12/30/1899 - thus, the DATEDIFF function would always return a negative value to your query, resulting in no hits.
"It's cold gin time again ..."
Check out my website here.
-
Aug 20th, 2003, 09:06 AM
#5
-
Aug 20th, 2003, 09:08 AM
#6
Thread Starter
New Member
Thats worked...so the resulting recordset will be details of logs that have a diference of 8 hours or more??
i'm pretty sure thats working...
THANX A LOT for that...its easy when you know how isnt it!
In the famous words of Vanilla Ice "word to ya mutha"
-
Aug 20th, 2003, 10:37 AM
#7
Thread Starter
New Member
is it possible to get the difference in minutes using a similar query?? for example 15 minutes instead of 8 hours? if so, how would this be done?
Regards
Chetz
In the famous words of Vanilla Ice "word to ya mutha"
-
Aug 21st, 2003, 12:51 AM
#8
Member
You can use 'n' to get a difference in minutes, here a full list of intervals You can use :
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
-
Aug 26th, 2003, 04:18 AM
#9
Thread Starter
New Member
thanx for that post..thats a great help 
just another quick question...i need this query to work over a 24hour period and maybe even over a few days..the application it is used in runs 24/7, would this still work?
In the famous words of Vanilla Ice "word to ya mutha"
-
Aug 26th, 2003, 06:15 AM
#10
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|