Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with DateTime and Int
Message
De
14/06/2019 12:27:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01669054
Message ID:
01669091
Vues:
43
>Note that in SQL Server the field type is DateTime and in VFP it is Date.
>
>Here is the exact version of filter expression that I use in the SQL Select (note that the AND in the begging of the expression is because there are other filter expressions):
>
>
>dPassDate = date()  && but could be a different date since user can change it from the current date to a future date
>IF plSqlServer
>	cLifeExpFilter = " AND (PURCHASED IS NOT NULL AND LIFE_EXP IS NOT NULL AND LIFE_EXP > 0 AND ('" + 
>DTOS(dPassDate) + "' >= DATEADD( year, LIFE_EXP, PURCHASED)) ) "
>ELSE
>        *-- VFP DB
>	cLifeExpFilter = " AND (!EMPTY(PURCHASED) AND LIFE_EXP > 0 AND '" + DTOS(dPassDate) + "' >= 
>DTOS(GOMONTH(PURCHASED,LIFE_EXP*12)))"
>ENDIF 
>
Then it is better, you don't need to cast (actually did the casting to remove time portion). Looks like you are using ADO (if not easier to write for ODBC):
IF plSqlServer
	cLifeExpFilter = " AND (PURCHASED IS NOT NULL AND LIFE_EXP IS NOT NULL AND LIFE_EXP > 0 AND ( " +;
                                 " ? >= DATEADD( year, LIFE_EXP, PURCHASED)) ) "
ELSE
        *-- VFP DB
	cLifeExpFilter = " AND (!EMPTY(PURCHASED) AND LIFE_EXP > 0 AND ?  >= GOMONTH(PURCHASED,LIFE_EXP*12))"
ENDIF 

dPassDate = date()  && but could be a different date since user can change it from the current date to a future date
* add m.dPassDate to parameters
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform