Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Posts
    3

    Post Unanswered: VB6 / SQL variable problem

    Hi,

    Can anyone help please, I am trying to feed a date variable (sysDate) into an SQL string and cannot figure out why it wont work.
    e.g.
    This works fine for a variable which is a string -
    "SELECT * FROM OWNER WHERE ownerid= ' " & sstr & " ' "

    VB documentaion says this should work for a date
    "SELECT * FROM OWNER WHERE owndate = # sysDate # "

    But it throws a runtime error, i've tried everything I can think of with no luck.

    Any help would be greatly appreciated.

    Thanks in advance

    NitrO

  2. #2
    Join Date
    Nov 2002
    Location
    Ohio
    Posts
    90
    Hi NitrO,

    Try this:

    "SELECT * FROM OWNER WHERE OWNDATE = #" _
    & Format(sysdate,"mm/dd/yyyy") & "#"


    That should ensure the sysdate is in a valid date format for the query.

    Good Luck,
    Bruce Baasch

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    Which database are you using ? What was the runtime error ?

  4. #4
    Join Date
    Dec 2002
    Posts
    3

    Talking

    Thanks Bruce,

    That did the trick. Bloody Access .. LOL

    Cheers,

    NitrO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •