Full Version: Between 2 dates over Midnight
UtterAccess Discussion Forums > Microsoft® Access > Access Date + Time
SSgtJ
I am sure this is posted somewhere else, but I cannot seem to find it with the Time aspect attached.
I have 3 fields in my query.
fldDate
fldTime
fldDateandTime
fld Date and Time is just Date and Time joined together.
Is there a way to write the Between function in the criteria field in the fldDateandTime field to be
"Between [startdate] #7:00AM# and [enddate] #7:00AM#"
as to return all the records for lets say the 18th at 7am to the 19th at 7am

I apologize in advance if this is basic.

thanks,
Mark
Peter46
Between ([startdate] + #7:00AM#) and ([enddate] + #7:00AM#)

Make sure that startdate and enddate are declared in the query parameters as datetime values.
SSgtJ
I want the [StartDate] and [EndDate] to be values entered by the person running the query so they are not actually fields in any table. I get an error when I enter that line in the criteria.
Here is the Sql for the query..

SELECT OnsiteGuestCount.OnSiteID, OnsiteGuestCount.CountDate, OnsiteGuestCount.CountTime, [OnSiteGuestCount].[CountDate] & ", " & [OnSiteGuestCount].[CountTime] AS DateandTime, OnsiteGuestCount.Poker, OnsiteGuestCount.BJ, OnsiteGuestCount.Slots, qry_Max_Times.MaxOfBJ, qry_Max_Times.theBJTime, qry_Max_Times.MaxOfPoker, qry_Max_Times.thePokerTime, qry_Max_Times.MaxOfSlots, qry_Max_Times.theSlotsTime, [MaxofSlots] & ", " & [theslotstime] AS HighCountSlots, [MaxofPoker] & ", " & [thePokertime] AS HighCountPoker, [MaxofBJ] & ", " & [theBJtime] AS HighCountBJ
FROM OnsiteGuestCount INNER JOIN qry_Max_Times ON OnsiteGuestCount.CountDate = qry_Max_Times.CountDate
WHERE ((([OnSiteGuestCount].[CountDate] & ", " & [OnSiteGuestCount].[CountTime]) Between ([startdate]+#12/30/1899 7:00:00#) And ([enddate]+#12/30/1899 7:00:00#)));

Thanks again,
Mark
SSgtJ
Bah.. I didnt read your post correctly.. Hahahaa I added the parameters and it works like a charm! thats what I get for being impatient.

Thanks!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.