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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:01:10+00:00 2026-06-11T00:01:10+00:00

I want to get entries from a SQLite database by date. SQLite valid timestring

  • 0

I want to get entries from a SQLite database by date.

SQLite valid timestring formats are listed here as:

YYYY-MM-DD
YYYY-MM-DD HH:MM
YYYY-MM-DD HH:MM:SS
YYYY-MM-DD HH:MM:SS.SSS
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.SSS
HH:MM
HH:MM:SS
HH:MM:SS.SSS
now
DDDD.DDDD 

I have another format in the database that is D/M/YYYY

Is there a way to compare dates in this database (and select entries accordingly) without having to select, parse and compare all the DateTime objects from all rows in the table?

  • 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-11T00:01:11+00:00Added an answer on June 11, 2026 at 12:01 am

    I made a really FAST query and I am proud of it :p. So here it is:

        public static string FromClausePartForDateComparisson(string tableName, string dateFieldName, string idFieldName, DateTime from, DateTime to)
        {
            string clause = string.Format(@" from 
               (SELECT {0} as filteredId,
                    Substr('00'|| -- make day with two digits
                        CASE Substr({1}.{2}, 3, 1)
                            WHEN '/' THEN Substr({1}.{2}, 1, 2)
                            ELSE Substr({1}.{2}, 1, 1)
                        END, -2, 2) AS DAY,
                    Substr('00'|| -- make month with two digits
                        CASE Length({1}.{2})
                            WHEN 8 THEN Substr({1}.{2}, 3, 1)
                            WHEN 9 THEN CASE Substr({1}.{2}, 3, 1)
                                            WHEN '/' THEN Substr({1}.{2}, 4, 1)
                                            ELSE Substr({1}.{2}, 3, 2)
                                        END
                            WHEN 10 THEN Substr({1}.{2}, 4, 2)
                        END, -2, 2) AS MONTH,
                    Substr({1}.{2}, Length({1}.{2}) - 3, 4) AS YEAR
                FROM   {1}
                WHERE  Strftime('%Y%m%d', YEAR||'-'||MONTH||'-'|| DAY) BETWEEN
                        Strftime('%Y%m%d', '{3}') AND
                        Strftime('%Y%m%d', '{4}')) AS filteredtable
                INNER JOIN {1} ON filteredtable.filteredId = {1}.{0} ", idFieldName, tableName, dateFieldName, from.ToString("yyyy-MM-dd"), to.ToString("yyyy-MM-dd"));
            return clause;
        }
    

    And it is being used as:

    var selectCommand = new SQLiteCommand("SELECT * " + 
        FromClausePartForDateComparisson("TABLENAME", "DATE", "ID", from, to) +
        @"WHERE ID_TABLENAME=@Id";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get the most recent 10,000 entries from CNN's top stories RSS
I get a dictionary and i want to get the matching database entries for
Thanks for looking, I'm trying to get 20 entries from the database randomly and
I want get as much as possible from Redis + Hiredis + libevent. I'm
What I want: get a xml from the AppData to use What I code
Basically I want get data I already have accessed from javascript and passing it
I want to get list of tables in a given database and a given
I want to get 100 and example from this string ?connect:100/username:example/ I searched in
I want to get the newest entries for each of my threads (private messaging
I have unix timestamps in my database. Now I want to get only results,

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.