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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:29:36+00:00 2026-06-13T13:29:36+00:00

I have a table in my sqlite3 databse which has the following fields: id

  • 0

I have a table in my sqlite3 databse which has the following fields:

id text not null, phonenum text not null, timeofcall text not null

The timestamp is basically the time of the insertion (in my app when a person calls it inserts the tele number and also the time of the call.)

I want to get all of the rows for a particular number within the last minute, something like:

SELECT * FROM callstbl WHERE phonenum = '07857463756' AND timeofcall < 1 minute ago;

How is something like this accomplished?

EDIT:

when i use this query as suggest by the top poster I get back every row that matches the ‘phonenum’, its like its ignoring the time function

String sql = "select * FROM callstbl WHERE timeofcall >= datetime('now', '-1 minutes') AND phonenum='"+num+"'";

The format of my date-time string (timeofcall) is yyyy-MM-dd HH:mm:ss

if i just do

SELECT * FROM callstbl WHERE timeofcall >= datetime('now', '-1 minutes');

I get back every row in the database.

  • 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-13T13:29:38+00:00Added an answer on June 13, 2026 at 1:29 pm

    I’d suggest its better to have a column say, timeOfCallMili in your table which stores the time in Miliseconds. This way it will be much easier for you to query based on date/time.
    Your query will be something like

    WHERE timeOfCallMili >= System.currentTimeMillis() - 60000 
    

    or say you want to get the records within 7 days old (or any specific date for that matter), you could just use a Calendar object to represent that date/time.

    Calendar queryTime = Calendar.getInstance(); //this instance gets the current date/time as default values
        queryTime.set(Calendar.DATE, queryTime.get(Calendar.DATE) - 7); //setting date to 7 days back
        queryTime.set(Calendar.HOUR, 0);    //setting time to 0, as its set to current time by default. 
        queryTime.set(Calendar.MINUTE, 0);
    

    So now your query becomes

         WHERE timeOfCallMili >= queryTime.getTimeInMillis();
    

    This way you get full flexibility on any type of time based query.

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

Sidebar

Related Questions

I have a database, which has a table with fields like title, album, artist...
I have a table in SQLite database of Android which has a column RANK
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation
I am having a table which has about 17 fields. I need to perform
I have a table login2 in /data/data/sankalp.jain.shre/databases/loginfinal.db. The database has been created correctly which
I have one sqlite database which has one table in which I store the
I have the following table of counters: CREATE TABLE cache ( key text PRIMARY
I have a SQLITE database with two tables. Table A has an integer timestamp
I have a table in my database in SQLITE which has x and y
I have created an SQLite database which has a table which stores temperature values.

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.