|
-
Sep 18th, 2000, 02:27 AM
#1
Thread Starter
Addicted Member
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.
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
-
Sep 18th, 2000, 05:23 AM
#2
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
-
Sep 18th, 2000, 07:30 AM
#3
Fanatic Member
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
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Sep 19th, 2000, 06:36 AM
#4
Thread Starter
Addicted Member
Cheers Gary - Worked a charm!
Ta!
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|