Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StartTime plus EndTime Must Equal 1 hour 1

Status
Not open for further replies.

surfbum3000

Technical User
Aug 22, 2003
156
US
My tbl4Sites has various StarTimes and EndTimes. I only want to see data where the StartTime and EndTime equals one hour. Both fields are text.
 
Code:
Where DateDiff("h",timevalue([StartTime]),timevalue([EndTime])) = 1
 
Oh ... sorry ... Did you mean that EndTime must be 1 hour after StartTime?
Code:
Where Hour(TimeValue([StartTime])) + 1 = Hour(TimeValue([EndTime))
But note that
[tt]
StartTime 03:59
EndTime 04:01
[/tt]
will satisfy that condition even though there are only 2 minutes between those times. Perhaps you want something more elaborate
Code:
Where Minute(TimeValue([EndTime])) - Minute(TimeValue([StartTime])) BETWEEN 60 AND 119
 
I haven't tried this out on all possibilities, but this seems to work in my testing.

Code:
WHERE DateDiff("n", [StartTime], [EndTime]) = 60
 
This is the code that worked:

SELECT tbl4Sites.Start_Time, tbl4Sites.End_Time, DateDiff("n",[Start_Time],[End_Time])=60 AS Expr1
FROM tbl4Sites
ORDER BY tbl4Sites.Start_Time;

The results in the Expr1 field is either a 0 or -1, with -1 equaling 1 hour.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top