Thank you for your answer.
Actually, I've tried with this function where I added the # symbol
between the date:
GetReturn<-function(code,date)
{
db<-"C:/Test.mdb"
channel<-odbcConnectAccess(db)
ssql<-paste("select * from tblCalendarDate Where CalendarID
=",code,"and DateRebal=
#",date,"#")
print(ssql) # so as i can see what ssql contains
mydata<-sqlQuery(channel,ssql)
mydata
}
GetReturn(1,"2007-01-10")
And it works when I run simply the command GetReturn(1,"2007-03-01")
"Samuel Bächler" <[EMAIL PROTECTED]> a écrit :
Hi Many
GetReturn<-function(code,date)
{
db<-"C:/Test.mdb"
channel<-odbcConnectAccess(db)
ssql<-paste("select * from tblCalendarDate Where CalendarID
=",code,"and DateRebal >=",date)
print(ssql) # so as i can see what ssql contains
mydata<-sqlQuery(channel,ssql)
mydata
}
[snip]
This is the content of my table tblCalendarDate:
CalendarID DateRebal
1 29/09/2006
1 10/10/2006
1 20/10/2006
1 31/10/2006
1 10/11/2006
1 20/11/2006
Actually, the channel is open but the query on the table did not
perform the query correctly, here is the
result of the function when i run GetReturn(1,"2007-03-01") for example:
Something with the formatting of the date goes wrong as I think. In
the table tblCalendarDate you have it
like *29/09/2006* but in your function you have it as
*"2007-03-01"*. Dig deeper by experimenting with
the dates format. You can experiment in Access itself to see what
kind of dates Access accepts.
s.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.