xain
xain

Reputation: 13839

Cast text to numeric in sqlite table definition

is there a cast in sqlite, I need this to work in a create table definition ...

....
mydatetime numeric not null DEFAULT (strftime('%Y%m%d%H%M','now', 'localtime')) );

thanks

Upvotes: 1

Views: 361

Answers (1)

newtover
newtover

Reputation: 32094

sqlite> .headers on
sqlite> CREATE TABLE t1 (mydatetime int not null DEFAULT (strftime('%Y%m%d%H%M',
'now', 'localtime')), otherval TEXT);
sqlite>
sqlite> INSERT INTO t1 (otherval) VALUES ('qwe');
sqlite> SELECT * FROM t1;
mydatetime|otherval
201201231947|qwe

Upvotes: 1

Related Questions