Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select with DateTime and Int
Message
From
14/06/2019 12:59:36
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01669054
Message ID:
01669097
Views:
54
Likes (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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform