PDA

View Full Version : VB6 / SQL variable problem


NitrO
12-09-02, 10:06
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

Bruce A. Baasch
12-09-02, 12:26
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,

rnealejr
12-09-02, 15:44
Which database are you using ? What was the runtime error ?

NitrO
12-10-02, 09:26
Thanks Bruce,

That did the trick. Bloody Access .. LOL

Cheers,

NitrO