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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:25:09+00:00 2026-05-30T22:25:09+00:00

I am a parsing a file into a sqlite database that contains dates in

  • 0

I am a parsing a file into a sqlite database that contains dates in the YYYY-MM-DD format. I want to store the entries into sqlite in such a way that I can sort the entries by date (strings not cutting it). What is the normal protocol for storing and ordering dates in sqlite? Should convert the dates into a number. Is there a way to convert YYYY-MM-DD dates into timestamps?

  • 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-30T22:25:10+00:00Added an answer on May 30, 2026 at 10:25 pm

    SQLite supports “DATE” in table creation. (More about that later.)

    CREATE TABLE test (dt DATE PRIMARY KEY);
    INSERT INTO "test" VALUES('2012-01-01');
    INSERT INTO "test" VALUES('2012-01-02');
    INSERT INTO "test" VALUES('2012-01-03');
    
    SELECT dt FROM test ORDER BY dt;
    2012-01-01
    2012-01-02
    2012-01-03
    

    Values in the form yyyy-mm-dd sort correctly as either a string or a date. That’s one reason yyyy-mm-dd is an international standard.

    But SQLite doesn’t use data types in the way most database workers expect it. Data storage is based on storage classes instead. For example, SQLite allows this.

    INSERT INTO test VALUES ('Oh, bugger.');
    SELECT * FROM test ORDER BY dt;
    2012-01-01
    2012-01-02
    2012-01-03
    Oh, bugger.
    

    It also allows different date “formats” (actually, values) in a single column. Its behavior is quite unlike standard SQL engines.

    INSERT INTO test VALUES ('01/02/2012');
    SELECT * FROM test ORDER BY dt;
    01/02/2012
    2012-01-01
    2012-01-02
    2012-01-03
    Oh, bugger.
    

    You don’t have to do anything special to store a timestamp in a date column. (Although I’d rather see you declare the column as timestamp, myself.)

    INSERT INTO test VALUES ('2012-01-01 11:00:00');
    SELECT * FROM test ORDER BY dt;
    2012-01-01
    2012-01-01 11:00:00
    2012-01-02
    2012-01-03
    Oh, bugger.
    

    SQLite will try to do the Right Thing as long as you feed consistent data into it. And it will sort dates correctly if you use the standard format.

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

Sidebar

Related Questions

I am parsing a mustache file into a string, and after that I want
I am parsing an XML file into a table and want to use the
I am parsing an XML file into a table and want to use the
I am reading a binary file into a parsing program. I will need to
I'm parsing a file that is set up like so: <blah-name name=Turkey> <blah-city name=Test/>
Perl is really good for writing the kind of string/file parsing programs that I
I'm parsing a source file, and I want to suppress strings. What I mean
I am parsing a log and inserting it into either MySQL or SQLite using
Question abstract: how to parse text file into two hashes in Perl. One store
I'm parsing an HTML file into a well-formed XML document using NekoHTML parser. However

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.