FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour rango dates
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: rango dates
Posted: Tue Jun 16, 2009 05:32 PM

Hello James,

with your filter you are testing if there is a booking exactly in this period.
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.

If think what I posted is the right filter:

set filter to ( dIniziale < AL .AND. dFinale > dal )

Best regards,
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Tue Jun 16, 2009 05:51 PM
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 (fw): Select all Collapse
  set filter to alltrim(tipoattrez) == cTipoAttrez .AND. CAMERA == nCamera  ;
      .AND. ;
      (;
      ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL );
      )



James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: rango dates
Posted: Tue Jun 16, 2009 06:24 PM
Jamse,

>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.

but if you change this record to a booking over the whole season shouldn'd there then be 2:
the whole season booking and the booking from 14-15.6.2009

I am not clear what the msginfo should report: the free places or the occupied one?

Best regards,
Otto
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 05:27 AM

Otto,

>but if you change this record to a booking over the whole season shouldn'd there then be 2:
>the whole season booking and the booking from 14-15.6.2009

Other than the dates, there are two other criteria which that record (recno 2) doesn't meet.

>I am not clear what the msginfo should report: the free places or the occupied one?

msgInfo() is returning the number of records that exist that overlap the desired booking date. If nRec>0 then you cannot make the booking.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: rango dates
Posted: Wed Jun 17, 2009 07:38 AM
Hello james,

I try to understand the conditions.
( DAL >= dIniziale .AND. DAL <= dFinale ) .OR. ( AL >= dIniziale .AND. AL <= dFinale )


Here a little graphic showing what I mean:




FALSE ( DAL >= dIniziale .AND. DAL <= dFinale )
FALSE ( AL >= dIniziale .AND. AL <= dFinale )

Both parts of the condition return false but the period is occupied.

Best regards,
Otto
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: rango dates
Posted: Wed Jun 17, 2009 08:03 AM
James ,
I try with this :

Code (fw): Select all Collapse
 If   aData[nY,nX]== "O"
           cTipoAttrez:="O"
            cTipoSol :=""
            cPosNome := ""
            nOmbrellone :=  (oDBeach)->camera
            nFila:=  (oDBeach)->Y
            cCaption2:="Ombrellone n.:"+str(nOmbrellone)+CRLF+"Fila:"+str(nFila)
            n:= nOmbrellone
            (oDPre)->(OrdSetFocus(3))
        set filter to alltrim((oDPre)->tipoattrez) == cTipoAttrez .AND. (oDPre)->CAMERA == n  ;
      .AND. ;
      (;
      ( (oDPre)->DAL >= dDataIniziale .AND. (oDPre)->DAL <= dDataFinale  ) .OR.;
      ( (oDPre)->AL >= dDataIniziale .AND. (oDPre)->AL <= dDataFinale  );
  )
            (oDPre)->(DbGoTop())
            DO WHILE !(oDPre)->(EoF())
                cPosNome := alltrim( (oDPre)->RAZSOC)
                cTipoSol := alltrim( (oDPre)->TIPSOL)
                nStato:=((oDPre)->stato)
                (oDPre)->(DbSkip())
             ENDDO
       endif


I try , it seem run but I not made all tests I 'm working with my friend to make all tests
Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: rango dates
Posted: Wed Jun 17, 2009 11:07 AM

Otto,
How You control if a room is free in your Whotel application ?
I want a room from 16.08.2009 to 20.08.2009 : your application not control it ?

Best Regards, Saludos



Falconi Silvio
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 12:41 PM

Otto,

>Both parts of the condition return false but the period is occupied.

While trying to fall asleep last night, I realized that my previous filter was not covering all conditions. You have pointed out one of those conditions and you are correct. There are more conditions also.

I am going to think about this some more this morning and run more tests. This is more complicated than it at first seemed. Now that I have had some sleep, maybe the little gray cells will be working better.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 01:00 PM
Silvio and Otto,

OK, after one cup of coffee (but no testing), I think this filter covers all conditions:

Code (fw): Select all Collapse
   set filter to alltrim(tipoattrez) == cTipoAttrez .AND. CAMERA == nCamera  ;
      .AND. ;
      (;
      ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL ) .OR. ;
      ( dIniziale < DAL .AND.  dFinale > AL ) ;
      )


Otto, it seems that we were both right and we were both wrong--the filter needs to include both of our filters.

Now I am going to do have another cup of coffee and do some testing.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 01:24 PM

OK, testing seems to confirm that the filter is working. If you use these test dates:

dIniziale:= ctod("14/01/2009")
dFinale := ctod("15/12/2009")

You will get nRecs=6 which is all records in the database that also meet the first two criteria (the non-date criteria). Before adding Otto's filter, nRecs would have been 0. Thanks Otto!

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 01:36 PM
Otto,

>Here a little graphic showing what I mean:

>FALSE ( DAL >= dIniziale .AND. DAL <= dFinale )
>FALSE ( AL >= dIniziale .AND. AL <= dFinale )

>Both parts of the condition return false but the period is occupied.

You are referring to my first filter, note that I changed it later to:

Code (fw): Select all Collapse
     ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL )

This would trap the condition in your graphic, but it was still missing the oposite of your graphic--when dIniziale <= DAL and dFinale was >= AL. These are now covered in the new filter.

Code (fw): Select all Collapse
      ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL ) .OR. ;
      ( dIniziale < DAL .AND.  dFinale > AL )


James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: rango dates
Posted: Wed Jun 17, 2009 01:51 PM

Hello James,

why do you think that the condition I posted should not work?

Best regards,
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 02:10 PM

Otto,

>why do you think that the condition I posted should not work?

>( dIniziale < AL .AND. dFinale > DAL )

Well because I tested it and it didn't as I pointed out in a previous message.

I have looked at it again and I realized that I was not seeing it properly. I was confusing DAL and AL. What I was thinking you had was this:

( dIniziale < DAL .AND. dFinale > AL )

But after looking at your filter again and making a slight modification this seems to work:

( dIniziale <= AL .AND. dFinale >= DAL )

It is important to add the = signs. It works the same as my previous filter but it is much simpler. I like it!

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: rango dates
Posted: Wed Jun 17, 2009 02:50 PM

Hello James,
thank you for your answer.
> I was confusing DAL and AL.
James, therefore I ask what you show in the msginfo.
It was not clear from the question Silvio posted what he really wants:
the free umbrellas or the occupied.

This with the equal signs is much depending of the purpose.
Silvio needs free umbrellas during the day in my case with WINHOTEL
I check if the night is free.
Best regards,

Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: rango dates
Posted: Wed Jun 17, 2009 03:22 PM

Otto,

>> I was confusing DAL and AL.
>James, therefore I ask what you show in the msginfo.
>It was not clear from the question Silvio posted what he really wants:
>the free umbrellas or the occupied.

It appears that he was looking to tell if an umbrella was reserved for a date range. However, it would seem to be a better user interface to just select a date and show all umbrellas that are not reserved. Maybe that is what he wants. Silvio?

Howerver, msgInfo() was just a quick test of the filter.

>This with the equal signs is much depending of the purpose.
>Silvio needs free umbrellas during the day in my case with WINHOTEL
>I check if the night is free.

Hmm. But, wouldn't it be the same? If a room is occupied for the night of the 15th, don't you consider the room occupied on the 15th? So, wouldn't you need the same filter?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10