Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite Update date SQL

SQLite Newbie

I am trying to update a table with a date.

Something like this:

Update MyTable Set MyCol=GetDate()

What is the correct syntax?

like image 792
Ian Vink Avatar asked Dec 29 '22 02:12

Ian Vink


2 Answers

 UPDATE table SET datecol=date('now')

This'll set the whole table to the date now.

 UPDATE table SET datecol=date('now') WHERE id=666

Or if it's a datetime column, datetime('now')

like image 55
Xorlev Avatar answered Jan 11 '23 07:01

Xorlev


You have a complete reference here.

To update to the current date/time do this:

update mytable set mycol=date('now')
like image 20
Amirshk Avatar answered Jan 11 '23 07:01

Amirshk