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

  • Home
  • SEARCH
  • 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 723993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:10:17+00:00 2026-05-14T06:10:17+00:00

Is there a way to create a table in sqlite3 that has a datetime

  • 0

Is there a way to create a table in sqlite3 that has a datetime column that defaults to ‘now’?

The following statement returns a syntax error:

create table tbl1(id int primary key, dt datetime default datetime('now'));

Update: Here’s the correct ddl courtesy of Sky Sanders:

create table tbl1(id int primary key, dt datetime default current_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-05-14T06:10:18+00:00Added an answer on May 14, 2026 at 6:10 am

    Try this:

    create table tbl1(id int primary key, dt datetime default current_timestamp);
    

    Background:

    The DEFAULT constraint specifies a
    default value to use when doing an
    INSERT. The value may be NULL, a
    string constant, a number, or a
    constant expression enclosed in
    parentheses. The default value may
    also be one of the special
    case-independant keywords
    CURRENT_TIME, CURRENT_DATE or
    CURRENT_TIMESTAMP. If the value is
    NULL, a string constant or number, it
    is inserted into the column whenever
    an INSERT statement that does not
    specify a value for the column is
    executed. If the value is
    CURRENT_TIME, CURRENT_DATE or
    CURRENT_TIMESTAMP, then the current
    UTC date and/or time is inserted into
    the columns. For CURRENT_TIME, the
    format is HH:MM:SS. For CURRENT_DATE,
    YYYY-MM-DD. The format for
    CURRENT_TIMESTAMP is “YYYY-MM-DD
    HH:MM:SS”.

    From http://www.sqlite.org/lang_createtable.html

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

Sidebar

Related Questions

My database (sqlite3), has two tables with the following schemas: CREATE TABLE log(d date,
Is there a way to create an FTS table in SQLite that is pre-populated
Is there a way to create a temporary table using the RMySQL package? If
Is there a way to set the PRIMARY KEY in a single CREATE TABLE
In SQL Server, there's no way to create a temp table on the fly
Is there any way to automatically create a trigger on creation of new table
Is there any way to update a table layout after it has been created?
Is there a way to create a callback function that fires when a list
Is there a way to alter/create tables in built in air database, other then
I just wanna ask if there's a way in C#/ASP.NET to create 'dynamic' tables/fields

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.