Unsure Why Select Statement Isn't Working

Forum for DBF Commander discussing.

Unsure Why Select Statement Isn't Working

Postby btorrean » Tue Jun 25, 2019 1:05 am

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
btorrean
 
Posts: 8
Joined: Sun Jun 23, 2019 7:40 pm

Re: Unsure Why Select Statement Isn't Working

Postby Admin » Tue Jun 25, 2019 9:17 am

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')
Best regards,
Oleg Zhechkov
User avatar
Admin
Site Admin
 
Posts: 124
Joined: Wed Apr 21, 2010 7:27 pm

Re: Unsure Why Select Statement Isn't Working

Postby btorrean » Thu Jun 27, 2019 11:03 am

Oleg,

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

Brian
btorrean
 
Posts: 8
Joined: Sun Jun 23, 2019 7:40 pm

Re: Unsure Why Select Statement Isn't Working

Postby Admin » Thu Jun 27, 2019 11:38 am

Brian, CTOD() means 'character to date'. More info is available here.
Best regards,
Oleg Zhechkov
User avatar
Admin
Site Admin
 
Posts: 124
Joined: Wed Apr 21, 2010 7:27 pm


Return to DBF Commander Professional

Who is online

Users browsing this forum: No registered users and 1 guest

cron