0

I have the query below in access and wanted to use it in VBA...

SQL = "UPDATE Sales SET Sales.order_date = CDate(Right([data],2)+" / "+Mid([data],5,2)+" / "+Left([data],4));"

I keep getting error due to the way I am building the string to then execute.

I have tried to put the

& "/" & 

to build the string but get an error when executing the SQL...

How should I build the string?

Thanks!!!

2 Answers 2

1

You would use DateSerial for this if data is a field of your table:

SQL = "UPDATE Sales SET Sales.order_date = DateSerial(Left([data],4), Mid([data],5,2), Right([data],2))"
Sign up to request clarification or add additional context in comments.

Comments

0

just escaped the / as '/' and worked...

SQL = "UPDATE Sales SET Sales.order_date = CDate(Right([data],2)+ '/' + Mid([data],5,2) + '/' + Left([data],4));"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.