Hello again I have variables in R that contains a date represented as a character string that I'd like to use to query an oracle SQL database for data dated between to endpoints. The string format is of the form "YYYY-MM-DD". I am using the examples given on db.rstudio.com as a reference. The <DATE_FIELD> variable on the Oracle SQL database is stored as a SQL date variable.
For example, I have wrote a query like this
library(tidyverse)
librar(odbc)
parameters <- c(date1, date2)
query <- c("SELECT * FROM SOME_TABLE
SOME OTHER STUFF
WHERE <DATE_FIELD>
BETWEEN TO_DATE(?, "YYYY-MM-DD")
AND TO_DATE(?, "YYYY-MM-DD")"
result <- dbSendQuery(connection, query) %>%
dBind(parameters)
result <- dbFetch(result)
I seem to be doing something wrong with the TO_DATE function, do I need to escape the question mark? How do I fix this.