Android Code Snippet Create SQLite field with default "date now" in milliseconds

fredo

Well-Known Member
Licensed User
DDL code:
B4X:
[entrCreate] INT NOT NULL DEFAULT (strftime('%s','now') *1000)
Make sure that the expression (strftime('%s','now') *1000) is enclosed in brackets.

B4X:
CREATE TABLE [tablexyz](
  [IDScd2] INTEGER PRIMARY KEY AUTOINCREMENT,
  [StatCat_id] INT NOT NULL DEFAULT (-1),
  [Scd_ArtName] TEXT NOT NULL DEFAULT '' COLLATE NOCASE,
  [Scd_YM] TEXT NOT NULL DEFAULT '' COLLATE NOCASE,
  [Scd_SumPrc] TEXT NOT NULL DEFAULT '' COLLATE NOCASE,
  [Scd_SumAmnt] TEXT NOT NULL DEFAULT '' COLLATE NOCASE,
  [Scd_Flags] TEXT NOT NULL DEFAULT '' COLLATE NOCASE,
  [Scd_ArtIdx] INT NOT NULL DEFAULT (-1),
  [entrCreate] INT NOT NULL DEFAULT (strftime('%s','now') *1000) ,
  [entrChange] INT NOT NULL DEFAULT (strftime('%s','now') *1000)
);
At each new row insert the fields [entrCreate] and [entrChange] are automatically filled with the Datetime.Now equivalent in epoch format:
16-04-_2018_08-52-51.png
 

yiankos1

Active Member
Licensed User
I expiriment this code right now, if i ORDER BY entrCreate ASC on a SELECT query, should it work correctly?
 
Top