R
Rose B
I am trying to do some checks in a module to highlight overlapping
dates/times. I have a query that has existing bookings, with 'StartTime' and
'EndTime' fields holding dd/mm/yyyy hh:nn data. I am passing to the module
the start and end times (also as full date/time fields) of the event that I
am trying to check - as vDateFrom and vDateTo arguments.
HOWEVER - I have a feeling (through various diagnostic messages) that the
tests are not using the time element of the fields from the query. (I could
be wrong - I know that dealing with dates/times is not as straightforward as
one might hope for!).
My code is .....
Set rst = CurrentDb.OpenRecordset("SELECT * from qryBookings WHERE (((# "
& Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") & "# > StartTime AND # " &
Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") _
& "# < EndTime) OR (# " & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# >
StartTime AND #" & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# < EndTime)))
OR (#" & Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") _
& "# < StartTime) AND (# " & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# >
EndTime) AND ResourceID = " & vResID & " AND BookingRef <> " & vBookRef)
The code runs, but records are selected that I don't think should be - and I
can't work out why!
If anyone can help to correct the above code - or suggest another way of
skinning this cat I will be very grateful.
Thanks in advance
dates/times. I have a query that has existing bookings, with 'StartTime' and
'EndTime' fields holding dd/mm/yyyy hh:nn data. I am passing to the module
the start and end times (also as full date/time fields) of the event that I
am trying to check - as vDateFrom and vDateTo arguments.
HOWEVER - I have a feeling (through various diagnostic messages) that the
tests are not using the time element of the fields from the query. (I could
be wrong - I know that dealing with dates/times is not as straightforward as
one might hope for!).
My code is .....
Set rst = CurrentDb.OpenRecordset("SELECT * from qryBookings WHERE (((# "
& Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") & "# > StartTime AND # " &
Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") _
& "# < EndTime) OR (# " & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# >
StartTime AND #" & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# < EndTime)))
OR (#" & Format(vDateFrom, "yyyy/mm/dd hh:nn:ss") _
& "# < StartTime) AND (# " & Format(vDateTo, "yyyy/mm/dd hh:nn:ss") & "# >
EndTime) AND ResourceID = " & vResID & " AND BookingRef <> " & vBookRef)
The code runs, but records are selected that I don't think should be - and I
can't work out why!
If anyone can help to correct the above code - or suggest another way of
skinning this cat I will be very grateful.
Thanks in advance