Re: [R] sqlQuery with date attribute

From: Samuel Bächler <linux_at_boeser.ch>
Date: Wed, 13 Aug 2008 12:02:29 +0200

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_at_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. Received on Wed 13 Aug 2008 - 08:05:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 13 Aug 2008 - 09:33:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive