Results 1 to 4 of 4

Thread: SQL Help needed!

  1. #1

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Unhappy

    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!"

  2. #2
    Guest

    Wink

    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

  3. #3
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    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


  4. #4

    Thread Starter
    Addicted Member Skeen's Avatar
    Join Date
    Jul 2000
    Location
    Abingdon, Oxon
    Posts
    138

    Thumbs up

    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
  •  



Click Here to Expand Forum to Full Width