I have an update clause in my ASP.NET MVC project and I just want to update single field using current time. I know I could also use GETDATE(), but I need to pass the date parameter from Service layer. So, the query is exactly as shown below and I also tried to use it on MSSQL Server, but encounter the same error: "Incorrect syntax near '.2019'."
UPDATE com.[Ticket] SET Updated = 29.04.2019 15:25:58 WHERE [Id] = 103
Here is the code side where I build the sql clause:
DateTime lastUpdate = DateTime.Now;
string sql = "UPDATE com.[Ticket] SET Updated = " + lastUpdate + " WHERE [Id] = " + model.Id;
Updated field is n datetime type. Do I have to format the date parameter in the update clause?