Help with ODBC Query for VBA

This is probably easy but I am having the toughest time.

I am wiritn an EXCEL macro that will access an Oracle Database. I need to filter through a field in date format. If I were explicit with the date I would simple have…

Where TABLE.MYDATA_DATE = {ts ‘2001-01-21 00:00:00’}

However, in the macro the date is not explicit, but would be entered upon prompting. So if it is stored, let’s say in , TheDate, how would I rewrite the above. Am I making any sense?

Here’s my best guess:

sql = "Select TABLE.MYDATA_VALUE "
sql = sql & "From TABLE "
sql = sql & “Where TABLE.MYDATA_DATE = {ts '” & TheDate & “’}”