How to update SQL date using NOW ()

Basically, I have a simple login form. In the database, I have a column called "last_logged" and I want to update it with the current date and time every time someone logs in.

I currently have this query:

    UPDATE users SET last_logged = "NOW()" WHERE id = 1

But it does not update the column to the current date. Any ideas why?

+5
source share
2 answers

Remove quotes from NOW(). As a function call, it must be incorrect.

UPDATE users SET last_logged = NOW() WHERE id = 1
+16
source

MS SQL uses GETDATE()insteadNOW()

(FYI only)
In SQL-Servernow I use SYSDATETIME():

DECLARE @now DATETIME = DATEADD(dd,DATEDIFF(dd,'19000101',SYSDATETIME()),'19000101');
+3
source

All Articles