Your problem is this:
".... WHERE ((tbl_campaign.cmp_date)=#" & datenow & "#)"
let's say your table has the following dates:
variable (which is confusingly named, you've set it to two days ago) has to match exactly
down to the millisecond
, very unlikely.
You need to re-work your SQL. I can't tell you what you need exactly as I don't have the requirement. But the equals isn't going to work.
You can use several functions, my best guess is you want to use datediff
] and find values = 2 days (or -2 days, depending which you put as start/end).
Finally building the query like this opens you up to SQL injection attacks, you should google "parametrised query". I think you don't need the parameter at all, the database can get today's date via http://www.w3schools.com/sql/func_getdate.asp
], again this depends on your requirements.
You a query along the lines of:
DATEDIFF(DAY, GETDATE(), tbl_campaign.cmp_date) = 2
This will get everything with a date two days into the future. Note, as you can use GetDate in the SQL, you don't have to pass it, closing the potential SQL Injection hole. The above works in SQL Server, YMMV if using something else.