How to make R accept characters that are part of Presto Query

Hello my dear friends ,
If i have a Query running at Presto , i need to run it at R using paste0(' ')
But some codes in this Query needs single Quotes. I tried to handle it by different methods but with no result and many errors :slight_smile:
The code as follows

WeekDetails<- paste0('
select 
                 week(date_add('day',1,InvoiceDate)) as Week,
                 B,
                 C,
                 D,
from Customers 
Where 
where InvoiceDate between cast( " ',StartDate , ' "as timestamp) and cast( " ',EndDate, ' " as timestamp)
and City='Cairo' ')

How can i handle characters that needs single Quotes and double Quotes ??
Errors are in lines 3,9,10
Appreciate your usual support please
Startdate and EndDate are parameters i need to input in R ShinyApp , 'day' needed to be in single quotes as a sql syntax , startdate and EndDate need to be in double quotes also as a concept in the Query

You'll need to escape the special characters (literal constants) using backslashes. See this StackOverflow thread, for example:

From the R Language Definition manual section on literal constants:

Quotes and other special characters within strings are specified using escape sequences :

\' single quote

\" double quote

1 Like