How to use dateRangeInput in sqlInterpolate in RShiny

I am trying to output a table that depends on a user selecting a date range in Shiny using sqlInterpolate. Although I have succeeded outputting a table based on a selectInput (dropdown), I can't figure out how to use a dateRangeInput with sqlInterpolate.

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND timestamp BETWEEN '2021-12-15' AND '2021-12-17'' at line 6 
pool <- dbPool(
  db = "db",
  user = user, 
  password = password, 
  host = host, 
  port = port

data_pool <- pool %>% tbl("table")

ui <- fluidPage(

server <- function(input, output, session) {
  output$daterange <- renderUI({
    dateRangeInput("daterange2", "Date:", start = "2021-12-15", end = "2021-12-17")
  data <- reactive({
    req(input$daterange2[1], input$daterange2[2])

    sql2 <- "
      STR_TO_DATE(timestamp, '%Y-%m-%d') AS timestamp
    FROM table
    WHERE timestamp BETWEEN ?date1 AND ?date2

    query <- sqlInterpolate(pool, sql2, date1 = input$daterange[1], date2 = input$daterange[2])
    dbGetQuery(pool, query)
  output$table1 <- renderTable({

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.