Hey guys I'm automating a report for work, and trying to incorporate a Date Variable into an SQL statement. Below is the Variable I have set up followed by the SQL Query I'm trying to run which errors out. The time is static because I need to run it for that full day, I just need to set the variable for the current month and date ("Now-7"). I would appreciate any help at all. Thanks in Advance.
qryDate = Now - 7
qryMonth = Month(qryDate)
qryDay = Day(qryDate)
qryYear = Year(qryDate)
qryDate = qryMonth & "/" & qryDay & "/" & qryYear
Set rstCount = conMain.Execute("select count(*)from SIEBEL.S_EVT_ACT where X_LOGIN_BRANCH like '__' and Qrydate and x_call_type like 'Inbound%'")
ExcelApp.Range("B4").CopyFromRecordset rstCount
rstCount.Close
qryDate = Now - 7
qryMonth = Month(qryDate)
qryDay = Day(qryDate)
qryYear = Year(qryDate)
qryDate = qryMonth & "/" & qryDay & "/" & qryYear
Set rstCount = conMain.Execute("select count(*)from SIEBEL.S_EVT_ACT where X_LOGIN_BRANCH like '__' and Qrydate and x_call_type like 'Inbound%'")
ExcelApp.Range("B4").CopyFromRecordset rstCount
rstCount.Close