According to this:
MySQL recognizes DATETIME and TIMESTAMP values in these formats:
As a string in either 'YYYY-MM-DD HH:MM:SS' or 'YY-MM-DD HH:MM:SS' format.
So one solution is to format your date in the right format:
now <- as.POSIXlt(Sys.time())
now.str <- format(now,'%Y-%m-%d %H:%M:%S')
now.str
[1] "2013-02-26 04:12:24"
or in this format
format(now,'%Y%m%d%H%M%S')
[1] "20130226041224"
Then update your table using dbSendQuery
. Here is an example for creating a dynamic query for any table and any date. Adapt it to your needs.
table.Name <- "MY_TABLE"
query <- paste(paste('UPDATE ', table.Name,sep=''),
paste('SET datetime_column =' ,"'",now.str,"'",sep=''),
'WHERE id=1',sep='\n')
cat(query)
UPDATE MY_TABLE
SET datetime_column ='2013-02-26 04:12:24'
WHERE id=1
dbSendQuery(con, query)
I think also that this should work with dbWritetable
, once you format your dates in the right format. But I don't have MySQL installed to test it. Try it and let me know if this helps.