quotation syntax

S

smk23

I am trying to pass a date (now) through a function into an SQL statement. I
can't get the double and single quotes to work.

What I have now is:
" ' " & Now() & " ' "

which is read by the function I am passing it to as " ' 10/22/07 18:30:00 '
" and thus fails. This passes directly to SQL so I need '10/22/07 18:30:00'
How do I do this?

Thanks
 
D

Douglas J. Steele

When you say "this passes directly to SQL", do you mean your query is
running as a pass-through query on SQL Server?

If so, just get rid of the spaces in your quotes: "'" & Now() & "'" (or " '"
& Now() & "' ")

If you're not using SQL Server, then Dennis is correct that you need to use
octothorpes (#) instead. Note, too, that unless you can be positive that all
users will have their Short Date format set to mm/dd/yyyy, you really should
format the date in such a way that you can be certain that Access will
interpret it correctly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top