Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with DateTime and Int
Message
De
14/06/2019 12:59:36
 
 
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:
01669097
Vues:
55
J'aime (1)
>>>>>>How would I change the above for VFP database? Does VFP have function similar to the SQL Server's DATEADD()?
>>>>>>
>>>>>>TIA
>>>>>
>>>>>Dmitry,
>>>>>
>>>>>You can GOMONTH(somedate, 12 * number of years) to get years advance (or step back).
>>>>
>>>>Antonio,
>>>>
>>>>Thank you very much! I didn't know of this function. This should do the job.
>>>
>>>How do I make an expression that I could use in the Where clause of the SQL Select (using the GOMONTH() approach). I have been trying many ways but still can't get it without an error.
>>>
>>>Here is one try:
>>>
>>>cWhereExpr = ['] + DTOS( dToday ) [' >= GOMONTH(PurchDate, Years*12 ) ]
>>>
>>>
>>>What is wrong with above?
>>
>>Dmitry, in VFP you must compare a date with a date, or a string with a string.
>>
>>So, either
>>
>>cWhereExpr = "'" + DTOS( dToday ) "' >= DTOS(GOMONTH(PurchDate, Years*12 ))"
>>
>>(in fact,
>>
>>cWhereExpr = "DTOS( dToday ) >= DTOS(GOMONTH(PurchDate, Years*12 ))"
>>
) or
>>
>>cWhereExpr = "dToday >= GOMONTH(PurchDate, Years*12 )"
>>
>
>Antonio,
>Your top choice (with DTOS()) works perfectly! Thank you!!

But the last example will be the fastest.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform