Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing date parameter into SQL string via VBA

616623Jan 8 2008 — edited Jan 8 2008
Hi folks

This is a bit of long shot, but does anyone know how to pass a date variable into an Oralce SQL string in VBA. Here's an example of the string:

SQLCommand.CommandText = "SELECT T104F005_EMPLOYEE_NO, " & _
"to_char(T104F025_DATE_EFFECTIVE, 'DD/MM/YYYY'), " & _
"from DATABASE.T104_EMPLOYMENT_HISTORY " & _
"where T104F025_DATE_EFFECTIVE > '1-JUL-07' " & _
"order by T104F005_EMPLOYEE_NO "

The statement "where T104F025_DATE_EFFECTIVE > '1-JUL-07' " needs to be a variable date which is captured in another step in the code, then passed into the SQL string. Does anyone know how this is done? I've tried declaring a parameter (eg :DateEffective) and using that, but the SQL string wouldn't recognise it. Perhaps it has something to do with the fact that the SQL string is text surrounded by quotes, thereby treating the parameter as text rather than a true parameter? Any suggestions? I will post this message on a VBA forum as well.

Cheers. Doug
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2008
Added on Jan 8 2008
2 comments
2,464 views