Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filtering a date
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01432041
Message ID:
01432090
Vues:
36
>>>Say, you pass month and year as two numbers
>>>
>>>Select * from myTable where ExitDate between 
>>>date(1,PassedMonth, PassedYear) and gomonth(date(1,PassedMonth, PassedYear),1) 
>>>into cursor curResults nofilter
>>>
>>>If you need it as a filter then
>>>
>>>SET FILTER TO between(ExitDate, date(1,PassedMonth, PassedYear), gomonth(date(1,PassedMonth, PassedYear),1) )
>>>
>>>assuming you may have an index on the date field.
>>
>>That will include values from next month 1st.
>>Also Date function accept parameters that way:
>>DATE(year, month, day), not DATE(day, month, year) :-)
>
>Good point. I was somehow thinking SQL Server and wanted to write
>= and <
but forgot at some point.
>
>Still the point is to use direct DATE comparision to make this query sargable as opposite to your and Tore's suggestions that would make this query non-sargable.


BETWEEN somefield XXXX AND YYYY is optimisable command
If you check I didn't used BETWEEN() function in SELECT (example 3).
CREATE CURSOR crsTest (Fld1 D)
INDEX ON Fld1 TAG crsTest

SYS(3054,12)
SELECT * FROM crsTest WHERE Fld1 BETWEEN DATE(2009,1,1) AND DATE(2009,12,31) INTO CURSOR crsTTT
SYS(3054,0)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform