Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select statements and date fields
Message
 
 
To
31/05/2007 16:19:41
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01229678
Message ID:
01229686
Views:
22
>Hi!
>
>How can I use the value of date field inside of a string whose content is a selec statement? Something like this.
>
>cdate=dtoc(table2.date)
>cSelect="selec * from table where table.date<="+cdate
>&cSelect
>
>TIA

Use this function to convert date to string variable suitable for select-SQL:
********************************************************************
*  Description.......: DateToStr - creates a date string from date
*  Calling Samples...:
*  Parameter List....: tdDate
*  Created by........: Nadya Nosonovsky 07/13/2001 02:52:32 PM
*  Modified by.......:
********************************************************************
FUNCTION DateToStr
LPARAMETER tdDate
LOCAL lcReturn
IF EMPTY(m.tdDate)
	lcReturn='{}'
ELSE
	lcReturn="{^" + (TRANSFORM(DTOS(m.tdDate), "@R 9999-99-99")) + "}"
ENDIF
RETURN m.lcReturn
So, your code would be

lcSelect = 'select ... where date = ' + DateToStr(ldDate) && where ldDate is a date variable

&lcSelect

This is for VFP native data.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform