how to format a date to be used in sqlstring in excel 2007?

R

ragup001

I have a startdate in cell a1 as 12/1/2006 and enddate in cell a2 as
12/31/2006. These are used as parameters for a sqlstring in excel 2007.
sqlstring = sqlstring & '12/1/2006' ,'12/31/2006'

Excel gives me a run-time error '1004' : SQL syntax error.

Can someone please tell me how to format the dates??

Thanks,

Ragup
 
M

mikearelli

Seems to me that whenever I have to deal with dates I have to use # before
and after the date. This may not be the case for you at all, but I'd try:
sqlstring = sqlstring & #12/1/2006# ,#12/31/2006#
 

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