[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
入門(寫過其他程式,只是對語法不熟悉)
[問題敘述]:
我想使用R的RODBC跟ORACLE資料庫相聯,並且撈回上個月月份的資料。
在我的資料表表單中,有一欄ACTDATE記錄時間,R讀取時是POSIXct格式
假設我想抓上個月份的資料,我該怎麼做?
[程式範例]:
程式不長我直接貼
Sys.setenv(TZ = "UTC") #設定時間
dataframe <- sqlQuery(conn, "SELECT ACTDATE,SECTOR,STD,STA
FROM TABLE
where months(ACTDATE) = months(Sys.Date())-1
Order by ACTDATE ")
感覺一定是怪怪的,但也不知該如何改
[環境敘述]:
sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 LC_CTYPE=Chinese
(Traditional)_Taiwan.950
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 LC_NUMERIC=C
[5] LC_TIME=Chinese (Traditional)_Taiwan.950
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mail_1.0 xlsx_0.5.7 xlsxjars_0.6.1 rJava_0.9-8 RODBC_1.3-14
loaded via a namespace (and not attached):
[1] tools_3.3.3
[關鍵字]:
RODBC