SQL dateadd function

Hi, I need to setup a sql job to send select query results in email using sp_send_dbmail.
I am able to run select query in query window without any issues. But When execute with sp_send_dbmail it throwing incorrect syntax near '2020' (msg 102, level 15 state1).

where class statement:
and datecolumn between '2020-09-30' and dateadd(hour, datediff(hour, 0, dateadd(mi, 30, getdate()))-1, 0)',

am I missing anything here. Please advise.

what is this syntax here? with the extra single quote and comma at the end?

between '2020-09-30' and dateadd(hour, datediff(hour, 0, dateadd(mi, 30, getdate()))-1, 0)',
1 Like

Thanks. Resolved. It was due to extra quote.