Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:58:43+00:00 2026-06-08T11:58:43+00:00

When defining a relation, I want to update an attribute to the timestamp at

  • 0

When defining a relation, I want to update an attribute to the timestamp at insert. For example, a working table that I have right now

CREATE TABLE t1(
id INTEGER PRIMARY KEY AUTOINCREMENT,
time TIMESTAMP
DEFAULT CURRENT_TIMESTAMP,
txt TEXT);

This is updating a timestamp on insert, for example, insert into t1 (txt) values ('hello') adds the row 1|2012-07-19 08:07:20|hello|. However, I want to have this date formatted in unixepoch format.

I read the docs but this wasn’t clear. For example, I modified the table relation to time TIMESTAMP DEFAULT DATETIME('now','unixepoch') but I get an error. Here, as in the docs, now was my time string and unixepoch was the modifier but it didn’t work. Could someone help me how to format it as a unixepoch timestamp?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T11:58:44+00:00Added an answer on June 8, 2026 at 11:58 am

    Use strftime:

    sqlite> select strftime('%s', 'now');
    1342685993
    

    Use it in CREATE TABLE like this:

    sqlite> create table t1 (
       ...> id integer primary key,
       ...> time timestamp default (strftime('%s', 'now')),
       ...> txt text);
    sqlite> insert into t1 (txt) values ('foo');
    sqlite> insert into t1 (txt) values ('bar');
    sqlite> insert into t1 (txt) values ('baz');
    sqlite> select * from t1;
    1|1342686319|foo
    2|1342686321|bar
    3|1342686323|baz
    

    See https://www.sqlite.org/lang_createtable.html#tablecoldef

    If the default value of a column is an expression in parentheses, then the expression is evaluated once for each row inserted and the results used in the new row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When defining parameter type that is e.g. in System.Data you have no intellisense and
My Case: I'm working on a system that will need to create various X12
By defining an attribute that implements IContactBehavior and IWsdlExportExtension and set that attribute on
I have a table defining ranges, e.g.: START | END | MAP 1 |
I'm defining a class that sets a Drawable attribute in an object. The problem
I'm trying to map a table (legacy from the Oracle Forms time) that have
When defining a resources in routes.rb in Rails, I have the following problem: My
After defining variables, functions, etc., can you save what you have done on the
Atleast defining my problem is simple... I have a Input control (Text) and a
When defining a custom operator from the limited set of single-character operators that can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.