Hi All,
I have a SQL date range query I need help with.
I have a mysql table called 'Booking' that has a number of fields with 2 being of type 'datetime' - 'start_date'
and 'end_date'.
I want to be able to query the two fields to see if a query date range falls within any of the records.
For example, I have 1 record in the booking table with a start date and time of, 01/01/08 00:00:00 and an end time of 25/01/08 00:00:00. I want to
build a query to say, give me a count of all records that have a booking between 12/12/07 00:00:00 and 05/01/08. In this example, I would get a count of 1.
Because I do not know how to do this, I am getting the total number of days of the query dates and then looping round each day and testing that date
against the record dates. If I find a match, I quit the loop and do not process the new booking. This is totally not the right way of doing it and positive there must be an easier way.
Thank you for looking guys...
P
I have a SQL date range query I need help with.
I have a mysql table called 'Booking' that has a number of fields with 2 being of type 'datetime' - 'start_date'
and 'end_date'.
I want to be able to query the two fields to see if a query date range falls within any of the records.
For example, I have 1 record in the booking table with a start date and time of, 01/01/08 00:00:00 and an end time of 25/01/08 00:00:00. I want to
build a query to say, give me a count of all records that have a booking between 12/12/07 00:00:00 and 05/01/08. In this example, I would get a count of 1.
Because I do not know how to do this, I am getting the total number of days of the query dates and then looping round each day and testing that date
against the record dates. If I find a match, I quit the loop and do not process the new booking. This is totally not the right way of doing it and positive there must be an easier way.
Thank you for looking guys...
P