Page 1 of 1

Unsure Why Select Statement Isn't Working

PostPosted: Tue Jun 25, 2019 1:05 am
by btorrean
Dear Forum,

I am trying to select all records in a DBF where the date in a field called, "datesigned," is on or before a certain date. I have checked that the field is indeed a, "Date," field, and DBF Commander shows that it is. However, all attempts at selecting the records has failed. I keep getting the error, "Operator/operand type mismatch." Please see the code from my latest attempt below. I have tried many iterations of adding single quotes around the date string in the query, adding or deleting spaces between the operator and the field name and such, but I keep getting the same error. Can anyone tell me what I am doing wrong?

Code: Select all
SELECT *
FROM "D:\My Documents\My Work\MY DBFs\Test.DBF"
WHERE datesigned<5/16/1997


Brian

Re: Unsure Why Select Statement Isn't Working

PostPosted: Tue Jun 25, 2019 9:17 am
by Admin
Hi Brian,
use the following syntax:
Code: Select all
SELECT *
FROM "D:\My Documents\My Work\MY DBFs\Test.DBF"
WHERE datesigned < CTOD('5/16/1997')

Re: Unsure Why Select Statement Isn't Working

PostPosted: Thu Jun 27, 2019 11:03 am
by btorrean
Oleg,

That worked! Can you tell me what CTOD is and why that needed to be used for the statement to work?

Brian

Re: Unsure Why Select Statement Isn't Working

PostPosted: Thu Jun 27, 2019 11:38 am
by Admin
Brian, CTOD() means 'character to date'. More info is available here.