views:

167

answers:

2

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?

+2  A: 

You have a complete reference here.

To update to the current date/time do this:

update mytable set mycol=date('now')
Am
Warning to OP: before running this code to test it, please make sure that you understand what it does and that it is what you want to do.
Mark Byers
@Marks is right, you should also add a __WHERE__ clause to affect only the relevant records.
Am
+2  A: 
 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')

Xorlev