Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select with DateTime and Int
Message
 
 
À
14/06/2019 11:23:13
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:
01669087
Vues:
42
>>>>>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!!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform