postgresqlから一連の日付を取得しましたが、正しく表示されます。
[1] "2007-07-13" "2007-07-14" "2007-07-22" "2007-07-23" "2007-07-24"
[6] "2007-07-25" "2007-08-13" "2007-08-14" "2007-08-15" "2007-08-16"
etc.
次に、それらに対してループを実行して、他のデータセットをフェッチするための新しいSQL文を作成します(はい、私が何をしているのかはわかっていますが、データベースサーバーですべての処理を行うことはできませんでした)
だから私は試しました
for(date in geilodates)
mapdate(date,geilo)
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR: invalid input syntax for type date: "13707"
LINE 1: ...id_date_location where not cowid is null and date='13707' or...
mapdateは私が書いた関数であり、その中での日付の使用は
sql=paste('select * from gps_coord where cowid=',cowid," and date='",date,"'",sep='')
したがって、SQLを一緒に貼り付けようとする前に、Rがフォーマットされた日付を整数表現にサイレントに変換したことが発生しました。
日付の元のテキスト表現を取得するにはどうすればよいですか?私は試した
for(date in geilodates){
d=as.Date(date,origin="1970-01-01")
mapdate(d,geilo)
}
Error in charToDate(x) :
character string is not in a standard unambiguous format
そして、日付文字列を作成する(または変数をリストするときに取得する文字列として日付を「提供」する)他の関数を見つけることができませんでした