Otto,
>with your filter you are testing if there is a booking exactly in this period.
No, I am testing to see if the new date range overlaps any existing date range.
>If you change for example the booking
>00002 Cliente H 3 1 01-01-2009 31-12-2009 .F. 1 0434 A 24-07-2002 GIOVANNI BIANCHI to a whole >year booking your code still returns 1.
As it should. There is one record that overlaps the new range.
>If think what I posted is the right filter:
>set filter to ( dIniziale < AL .AND. dFinale > dal )
No, this is not correct. Here is an eample:
We want to book from 14/06/2009 - 15/06/2009 (dIniziale - dFinale)
There is a record with a booking from 13/06/2009 - 14/06/2009 (DAL - AL). By your example:
set filter to 14/06/2009 < 14/06/2009 .and. 15/06/2009 > 13/06/2009
The first condition will fail (leaving no record meeting the filter), yet you cannot book 14/06/2009-15/06/2009 because 14/06/2009 is already booked.
What we really want to know is if dIniziale is within any existing date range OR if dFinale is within any existing date range. This would actually be a better way to write the filter (it makes it more clear).
- Code: Select all Expand view
set filter to alltrim(tipoattrez) == cTipoAttrez .AND. CAMERA == nCamera ;
.AND. ;
(;
( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
( dFinale >= DAL .AND. dFinale <= AL );
)
James