0

I have a database on phpmyadmin and have a column called "Date" that has date as type.

Now I would like to push a value into this column but I do not seem to get it into the database into the right way.

I have the value var1 that is of date class.

class(var1)
[1] "Date"

And is structured in the right way:

> var1
[1] "2016-02-22"

But still when I do:

 fn$dbGetQuery(con, "INSERT INTO weather(Date) VALUES('$var1')")

The following values are pushed into the database: 0000-00-00

That's strange cause when I enter:

fn$dbGetQuery(con, "INSERT INTO weather(Date) VALUES('2012-02-02')")

It does work. But either of this:

var1
[1] "2016-02-22"
fn$dbGetQuery(con, "INSERT INTO weather(Date) VALUES('var1')")
fn$dbGetQuery(con, "INSERT INTO weather(Date) VALUES('$var1')"

Does not seem to work. Any thoughts on what goes wrong here?

John Dwyer
  • 189
  • 2
  • 13

0 Answers0