I am struggling trying to update a row in an Azure SQL database. What I am trying to do is to update a row with some input variables along with a fresh datestamp. If I input the following (for test purposes), my database is updated, but the date is way off:
"UPDATE TABLENAME set COL1 = ".$_POST[VAL1].", COL2 = ".$_POST[VAL2].", COL3 = 2020-03-20 WHERE COL0 = 'VAL0'"
giving me a datestamp looking like this: 1905-06-21T00:00:00.0000000
I have been trying just around a hundred ways of formatting the date()
variable, putting it in my SQL statement like this:
"UPDATE TABLENAME set COL1 = ".$_POST[VAL1].", COL2 = ".$_POST[VAL2].", COL3 = ".date()." WHERE COL0 = 'VAL0'"
Needless to say, COL3
is my datestamp column. But I cannot get the database to accept my datestamp formatting. I have tried YYYY-mm-dd xyz1234 in countless variants inside date()
, but to no avail.
The database has the following collation set: SQL_Latin1_General_CP1_CI_AS.
Any pointers?