sqldf and filter by date

#1
Dear All,

Below is a bug that I am not able to filter the data by date. What I need to do is assign parameters date and select the store between these dates. I want to do this by sql ,if other ways available please let me know.
Thank you.

PHP:
test1 <- data.frame(open_date = as.Date(c("2011-08-01", "2012-12-09","2011-01-03")),store=c("a","b","c"))
date1=as.Date("2011-07-01")
date2=as.Date("2011-09-01")
df=sqldf("select * from test1 where open_date between 'date1' and 'date2'")
 
Last edited:

vinux

Dark Knight
#2
Try this way
Code:
date1=as.Date("2011-07-01")
date2=as.Date("2011-09-01")
s <- paste("select * from test1 where open_date between ", as.numeric(date1)," and ",as.numeric(date2) )
sqldf(s, verbose = TRUE)