The exact error i'm getting is
Could not convert variant of type (UnicodeString) into type(Date).
The variable I am using for the date is a string and I have to place quotation marks around it or else it returns null but when I put the quotation marks around it I get this error.
Here is my code for the SQL Query and the variable TodaysDate
. (This code isn't copy and pasted due to it being on a different machine without internet capabilities so please ignore anything that might cause a compiling error)
if MidStr(DateToStr(Date),2,1) ='/' then
TodaysDate := MidStr(DateToStr(Date),6,4) + '-' + '0' +
MidStr(DateToStr(Date),1,1) + '-' + MidStr(DateToStr(Date),3,2)
else
TodaysDate := MidStr(DateToStr(Date),7,4) + '-'
+ MidStr(DateToStr(Date),1,2) + '-' + MidStr(DateToStr(Date),4,2);
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT tbl.emailAddress, tbljob.Time FROM '+
'dbwindowwash.tblclient, dbwindowwash.tbljob, dbwindowash.tbljobclientworker '+
'WHERE tbljobclientworker.jobID = tbljob.jobID AND '+
'tbljobclientworker.clientID = tblclient.clientID AND tbljob.Date = ' +
QuotedStr(TodaysDate));
ADOQuery1.Open
// More Code using the email addresses and time
Copy and pasted straight into the Workbench this query gives me all the data I want but in Delphi gives me and error and with no QuotedStr()
it returns null in both Delphi and Workbench.
I have a similar query in my program elsewhere which uses the date as a string with QuotedStr()
and it works fine so I have absolutely no idea what is wrong with this.