r向SQL查询输入的闪亮日期范围

r向SQL查询输入的闪亮日期范围,第1张

r向SQL查询输入的闪亮日期范围

sub
通过简单地使用正则表达式来使用函数来做到这一点

my_date1 <- "08/01/2014"my_date2 <- "08/31/2014"my_query <- 'Select * from dbo.Employee where StartDate between DATE1 and DATE2 order by StartDate'my_query <- sub("DATE1",my_date1,my_query);my_query <- sub("DATE2",my_date2,my_query)# the result of your query is belownoquote(my_query)# if you want the quotes for dates leave them theremy_query <- 'Select * from dbo.Employee where StartDate between "DATE1" and "DATE2" order by StartDate'my_query <- sub("DATE1",my_date1,my_query);my_query <- sub("DATE2",my_date2,my_query)# the result of your query is belownoquote(my_query)# Now sub the inputs into those variables like somy_query <- 'Select * from dbo.Employee where StartDate between DATE1 and DATE2 order by StartDate'my_query <- sub("DATE1",input$daterange[1],my_query);my_query <- sub("DATE2",input$daterange[2],my_query)noquote(my_query)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5014721.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存