You probably need single quotes around the value returned from Sys.Date(). This should work
TODAY <- Sys.Date()
sqldf(paste0("SELECT * FROM DATA",
" WHERE DATE < '", TODAY, "'",
" ORDER BY DATE DESC LIMIT 1"))
This would generate the following raw query:
SELECT *
FROM DATA
WHERE DATE < '2018-03-29'
ORDER BY DATE DESC
LIMIT 1
This query will return the most recent record in your data happening before today.
Note that building a SQL string using raw concatenation like is generally bad. But if you are just doing it from your R console for some data analysis, then it should be acceptable.
data
DATA <- data.frame(DATE = c(Sys.Date() + 5:10, Sys.Date() - 5:10))
maxonly allowed in the result set (left ofwhere)?)