Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 6.0 ODBC Date problem

Status
Not open for further replies.

jdogg1

Technical User
Nov 18, 2001
8
US
I've got a query on a PHP page that accesses a VFP DBF file. The query looks like this:

"SELECT COUNT(IDNO) FROM ZMR
WHERE $race_fields[$i] = 'Y'
AND RACE = '$race_codes[$i]'
AND IDNO IN (SELECT IDNO FROM ZENROLL
WHERE ENRL_DATE BETWEEN {{$t1}} AND {{$t2}} AND EMPTY(ENRL_DATE) = .F.)";

ENRL_DATE is a date field. The problem is, this query never returns any records, even though it should (because I'm still testing it using valid dates). I've tried the subquery by itself and narrowed the problem down to:

ENRL_DATE BETWEEN {{$t1}} and {{$t2}}

$t1 and $t2 are strings in the format 'yyyy-mm-dd'.

I've also tried using the carat (^), but to no avail.

Please help me if you can.

Thanks.
 
In answering a similar question, Anders Altberg (my SQL "hero") answered as follows:
Code:
WHERE fldDate = DATE(2001,1,1)
WHERE fldDate = {^2001-01-0}
WHERE fldDate = {d, '2001-01-01'}
WHERE fldDate = CTOD( '2001-01-01')
/ or - or . as marks should all be ok.

The helpfile for VFPODBC is drvvfp.hlp. The latest VFPODBC version was in MDAC 2.5 I believe. It can be downloaded from MSDN's FoxPro site.

-Anders"

Rick


 
Actually, the problem was the curly braces around $t1 and $t2. I think they confused PHP. I changed the syntax a little and it works now. Thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top