Q:

Runtime Error-2147217904(80040e10)

I have Transactions table, in the table I have DOT(Date Of Transaction) field. I want to get transactions of a particular month in a particular year, irrespective of day. So tried by this Query.
>>>  SQL = "SELECT * FROM Transactions
WHERE DATEPART(MM, (SELECT DOT FROM Transactions))= " & Month(Date) & " 
AND DATEPART(YY, (SELECT DOT FROM Transactions))= " & Year(Date) & ""

but I am getting automation error and error showing at  rs.Open SQL, cnn.
where rs is recordset object , cnn connection object.

A:

The perfect query is below:
SQL = "SELECT * FROM Transactions t WHERE DATEPART('m', t.[DOT])= MONTH(DATE()) " & _ 
      "AND DATEPART('yyyy', t.[DOT])= YEAR(DATE())"

