ROracle date manipulation

99 views Asked by At

I installed ROracle on my computer and successfully connected to a remote Oracle database. I can interact with the tables using dbplyr and collect the data on my computer. But when I try to filter the date columns using dplyr filter function I get error like this:

Error in .valueClassTest(ans, "data.frame", "fetch") : invalid value from generic function ‘fetch’, class “try-error”, expected “data.frame”

The date columns display as datetime but the lubridate functions do not work (fe converting datetime to date using as_date) on them, but do not throw any error and base-r as.Date throws this error:

Error in .oci.SendQuery(conn, statement, data = data, prefetch = prefetch,  : 
  ORA-00936: missing expression

If I collect the data on my computer the datetime columns display correctly and work with all aformentioned functions.

Thank you.

1

There are 1 answers

0
ayasugihada On

Solved the issue by using SQL native function in dplyr pipe with right date mask.

#setup db connection con... 
tbl(con, "my_tbl") %>%
        filter(Dates_column <= to_date('04.11.2021','DD.MM.YYYY'))