On 6/18/2012 12:02 PM, [email protected] wrote:
Now the question, is it ok to use the sqlite3 DATETIME('now') function
to store the
data in sqlite and "parse/split" it when it is retrieved from the GUI
into date and time part ?

I don't see why not.

In this case I thought of a trigger to fill the db automatically
-- ********************************************************************
CREATE TRIGGER insert_t1_timestamp AFTER  INSERT ON t1
BEGIN
  UPDATE t1 SET timestamp = DATETIME('NOW')  WHERE rowid = new.rowid;
END;
-- ********************************************************************

Just put "DEFAULT CURRENT_TIMESTAMP" clause on timestamp column in CREATE TABLE. You don't need any triggers.

If I dont use the trigger, would I comitt a string to my timestamp column ?

I'm not sure I understand the question. Note that DATETIME('NOW') actually produces a string. SQLite doesn't have a dedicated type for dates, times or timestamps.

Has someone an example ?

An example of what?

And the other way, if I select from the db, how to I get the timestamp
in the
c++ prog ?

The same way you retrive the value from any other column. I'm not sure I understand the nature of the problem.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to