fromat SQL string to use in procedure

  • Thread starter Thread starter tim johnson
  • Start date Start date
T

tim johnson

I am unable to get the correct format for this SQL
statement so I can use it as a string in a procedure.


This is what I have but it does not work

Thanks for any help

strSQL = "SELECT ApptDate FROM tblAppointment " & _
"WHERE AppDate = & "#" & ApptDate & "#"


Note: ApptDate datattype = Date/Time
 
Your string contains an extra amperssand and quote mark. Try:

strSQL = "SELECT ApptDate FROM tblAppointment " & _
"WHERE AppDate = #" & Format(ApptDate, "mm\/dd\/yyyy") & "#"

The explicit formatting makes sure the date is in the American format
expected in SQL strings.
 
Back
Top