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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

operator/operand mismatch with dates -vfp/sql

Status
Not open for further replies.

foxbldr

Programmer
Apr 16, 2002
109
CA
Hi all,

I am using follwing sql statement to fetch date from sql server.

lcsql="select ......,{ d '1900-01-01' } as TEMP_DT..."

when I use following in my code,SOMETIMES, I get operator/operand mismatch error .
Code:
select lcCursor
do while !eof()
if TEMP_dt=date(yyyy,mm,dd) && error appears here

endif

enddo

I changed if statement to :
ttod(TEMP_dt)=date(yyyy,mm,dd), but still I get the error.

Any suggestions?


Thanks you all in advance.

 
RickSchummer,

I get the field(TEMP_DT) as a Datetime field.

Foxbldr
 
This is probably happening because temp_dt is a logical ( .F. ). Variables declared as LOCAL in scope are intitialized to .F. I suspect that therre is a flaw in your code that occasionally does not initialize temp_dt to a value and that is when you are seeing this error.



Marcia G. Akins
 
Foxbldr,

What I was indicating in my message (obviously not as clear as I would have liked {g}) is that you comparison will never work since the time portion of the comparison will make it not be equal.

Double check the values passed into the DATE() function. I am guessing that YYYY, MM, and DD are the problem here.

_RAS
VFP MVP
 
RickSchummer,

Your assumption is correct. I use SQLEXEC function in a class(written in vfp 8) that connects to Sql2K server for retrieving data.

Actually, right part of my comparison is always
"Date(1900,01,01)" and VFP's TTOD function returns date from a datetime expression. Vartype(TEMP_DT)always returns "T"(datetime). It returns "T"(datetime) even with zero records in cursor.

My cursor is an updatable cursor and I update the field TEMP_DT. When the field value is the original value, I am executing some more code. i.e.
Code:
IF TTOD(TEMP_DT)=date(1900,01,01)
...........
..........
.......
ENDIF



tx

foxbldr



 
foxbldr,

Stumped me. Without the actual data in front of me, with the basic assumption that Temp_dt is really a DateTime data type, your code should work fine.

Are you sure the error reported is for the correct line number? Are you popping into the debugger and checking out the environment?


_RAS
VFP MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top