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 8917667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:32:50+00:00 2026-06-15T05:32:50+00:00

Take this sqlite3 interactive session: sqlite> create table d(t date); sqlite> insert into d

  • 0

Take this sqlite3 interactive session:

sqlite> create table d(t date);
sqlite> insert into d values('1913-12-23');
sqlite> select t,typeof(t) from d;
1913-12-23|text
sqlite>

Why is the date field showing up as type text? Would storage space be smaller and queries be faster if it were numeric?

Sqlite3 datatype documentation shows that the affinity for date columns is numeric according to the table in §2.2. I would guess that date fields stored as numeric values as opposed to text would take up less space, so that would be ideal. I could very well not have a good grasp of sqlite yet, so my concerns may be invalid.

For easy copy/paste:

create table d(t date);
insert into d values('1913-12-23');
select t,typeof(t) from d;
  • 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-15T05:32:51+00:00Added an answer on June 15, 2026 at 5:32 am

    The reason that typeof('1913-12-23') returns text is that '1913-12-23' is a string, and is stored in the table as a string.
    Type affinity comes into play only when the conversion would be lossless; e.g., the value '123456' would be converted into a number.

    SQLite does not have a native date data type.
    To allow dates to be handled by the built-in date functions, you have to store them either as yyyy-mm-dd strings or as numbers (either Julian day numbers, or seconds since the Unix epoch).

    Integers take up less storage than strings, so queries are faster if the DB’s bottleneck is I/O, which is likely.

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

Sidebar

Related Questions

im getting this error: cursor.execute('INSERT INTO COURSE (title) VALUES (?)',(title)) sqlite3.ProgrammingError: Incorrect number of
How to take two values into sqlite3 ? v1 = '2011.11.10' v2 = 10
I have a table looking like this created with sqlite. CREATE TABLE Cars (
Take this query: SELECT * FROM MyTable WHERE MyColumn = 'SomeValue' ORDER BY SomeFakeQualifier.MyColumn
Take this code into consideration: Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port)); try
If i have code like this $dbSL = Zend_Db::factory('pdo_sqlite', array('dbname'=>':memory:')); $dbSL->query('CREATE TABLE ...'); $dbSL->query('CREATE
I have an sqlite table with a few hundred million rows: sqlite> create table
Ran into this error message whilst developing tonight: SQLite3::BusyException: database is locked: I have
I have the following error during sqlite3-ruby install: Building native extensions. This could take
it says Building native extensions. This could take a while... ERROR: Error installing sqlite3:

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.