quotation syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
Back
Top