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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:50:31+00:00 2026-05-24T10:50:31+00:00

I am storing values from Calendar.getTime() in my SQLite database field called ‘Created’ when

  • 0

I am storing values from Calendar.getTime() in my SQLite database field called ‘Created’ when new records are inserted..

The field is ‘datetime’ and it stores values in this format : EEE MMM dd HH:mm:ss z yyyy.

My app has 2 datepickers so you can select a start and end date/time to create a range – all I need to do is run a query to return records which were created within this timespan but it is giving me a major headache!

My query looks like this :

public Cursor GetAllByDateRange(Date dtStart, Date dtEnd) {

    return database.query(DATABASE_TABLE, new String[] { 
            KEY_id, KEY_CREATED, KEY_VALUE, KEY_DESCRIPTION, KEY_ISEXPENSE}, 
            KEY_CREATED + " BETWEEN '" + dtStart + "' AND '" + dtEnd + "'",
            null, null, null, KEY_CREATED + " DESC");
}

I think I understand the problem but not how to resolve it, I believe this approach will not work because SQLite stores dates in String format (if this is true I’m not sure why they even have a Date’ type!), so they get compared as Strings rather than dates..

It appears my options are limited because I need to record time as well as the date, having spent most of today trawling the web I am at a complete loss – can anyone suggest how I can move forward?

Thanks!

  • 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-24T10:50:32+00:00Added an answer on May 24, 2026 at 10:50 am

    If possible, store your dates as integers in the datbase, storing the milliseconds value from date.toTime(). It’s then much easier to instantiate a date object from new Date(milliseconds) and you can then format the output according to the locale.

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

Sidebar

Related Questions

I am fetching values from a number of text fields and storing their values
I'd like to build a query string based on values taken from 5 groups
How can I change values in string from 0,00 to 0.00? - only numeric
How would I return multiple values (say, a number and a string) from a
I have a with dynamic values from an Enum like: String, Int, Double, Bool,
Basically, I have a gridview that is opened in a new window from the
I am having a textbox field in my jsp called req_date. The user is
I am working on a project that obtains values from many measurement stations (e.g.
I need to copy data from one database into my own database, because i
I am using the exact examples from the Google Calendar API in C#: string

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.