I'm using dbGetQuery in R to fetch result.
df <- dbGetQuery(conn, "SELECT * FROM orders WHERE invoice_date >= '2020-08-31 00:00:00.00000+00'")
I want to assign date to a variable and call it in query. Something like this,
invoice_date <- '2020-08-31 00:00:00.00000+00'
df <- dbGetQuery(conn, "SELECT * FROM orders WHERE invoice_date >= {invoice_date}")
How can I achieve this?
paste("SELECT invoice_date,order_id, product_code, delivery_pincode,fulfilment_center FROM sales_report WHERE invoice_date >= ", invoice_date, "", sep="")but it is not taking as character with quotesinvoice_date <- "'2020-09-03 00:00:00.00000+00'" df <- dbGetQuery(conn, paste("SELECT invoice_date,order_id, product_code, delivery_pincode,fulfilment_center FROM sales_report WHERE invoice_date >= ", invoice_date, "", sep="").Thanks !! But I'm accepting @Waldi's answer since it's more cleaner approach.