-
I'm trying to execute the following SQL Statement and I'm getting an error message "Invalid column name", but the spelling is ok. So I wondered if it was referring to the data type, as I'm using dates. Do I need to declare the columns 'StartDateTime' & 'EndDateTime' as date variables rather than just strings? If so how do I do this?
SQL:
cmmSQL = "SELECT StartDateTime, EndDateTime, DurationSecs, CallersNumber, DialledNumber,TerminatingNumber, ValuePence FROM Opal_Data WHERE
TerminatingNumber = '" & PRSselecta & "'
AND StartDateTime >= TODATE('" & Starter & "', 'DD/MM/YYYY HH:MM:SS')
AND EndDateTime <= TODATE('" & Ender & "', 'DD/MM/YYYY HH:MM:SS') "
Cheers 'n' Beers....
Skeen.
-
Hi Skeen stay on the scene.
I've never used todate yet so I don't know if this causes the error.
But if you're sure all column names are spelled correct then
this could be the problem.
You can convert your string to a datetime like this,
and give it without the ' '
Dim MyDate As Date
Dim e As String
e = "01/12/1998"
MyDate = e
Hope this is what you needed
-
Skeen
Post or check the SQL string after it has been built and before it is run.
The AND StartDateTime >= and AND EndDateTime >= should look somthing like this
WHERE EndDateTime<=#11/11/00 5:30:00 PM# AND StartDateTime>=#1/1/00 5:30:00 PM#;
Hope this helps
-
Cheers Gary - Worked a charm!
Ta!