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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:52:16+00:00 2026-06-03T20:52:16+00:00

I am trying to fetch results from my sqlite database by providing a date

  • 0

I am trying to fetch results from my sqlite database by providing a date range.
I have been able to fetch results by providing 3 filters

        1. Name (textfield1) 
        2. From (date)(textfield2)
        3. To   (date)(textfield3)

I am inserting these field values taken from form into a table temp using following code

        Statement statement6 = db.createStatement("INSERT INTO Temp(date,amount_bill,narration) select date,amount,narration from Bills where name=\'"+TextField1.getText()+"\' AND substr(date,7)||substr(date,4,2)||substr(date,1,2) <= substr (\'"+TextField3.getText()+"\',7)||substr (\'"+TextField3.getText()+"\',4,2)||substr (\'"+TextField3.getText()+"\',1,2) AND substr(date,7)||substr(date,4,2)||substr(date,1,2) >= substr (\'"+TextField2.getText()+"\',7)||substr (\'"+TextField2.getText()+"\',4,2)||substr (\'"+TextField2.getText()+"\',1,2) ");
                    statement6.prepare();
                    statement6.execute();       
                    statement6.close(); 

Now if i enter the following input in my form for the above filters

               1.Ricky
               2.01/02/2012
               3.28/02/2012

It fetches date between these date ranges perfectly.
But now i want to insert values that are below and above these 2 date ranges provided.

enter image description here

I have tried using this code.But it doesnt show up any result.I simply cant figure where the error is

The below code is to find entries having date lesser than 01/02/2012 and greater than 28/02/2012.

          Statement statementVII = db.createStatement("INSERT INTO Temp5(date,amount_rec,narration) select date,amount,narration from Bills where name=\'"+TextField1.getText()+"\' AND substr(date,7)||substr(date,4,2)||substr(date,1,2) < substr (\'"+TextField2.getText()+"\',7)||substr (\'"+TextField2.getText()+"\',4,2)||substr (\'"+TextField2.getText()+"\',1,2) AND substr(date,7)||substr(date,4,2)||substr(date,1,2) > substr (\'"+TextField3.getText()+"\',7)||substr (\'"+TextField3.getText()+"\',4,2)||substr (\'"+TextField3.getText()+"\',1,2)");
                    statementVII.prepare();
                    statementVII.execute();       
                    statementVII.close(); 

Anyone sound on this,please guide.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-06-03T20:52:18+00:00Added an answer on June 3, 2026 at 8:52 pm

    you need to use an Or clause together with brackets:

    WHERE name='....' AND (yourDateField<yourLowerDate OR yourDateField>yourHigherDate)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very weird results when trying to fetch the AVG() field from
I am trying to fetch data from SQLite database(NSArray of strings) and populate the
I'm trying to fetch the most popular tags from all videos in my database
I am trying to fetch records from Oracle 9i database whose value are 'FOO
I'm getting terribly slow results from the following code. I've been trying to troubleshoot
So I'm trying to fetch objects from core data. I have list of say
I'm trying to calculate whether the results i get from the database are made
I want to be able to fetch results from mysql with a statement like
I'm trying to pull some results from a database but I guess I'm kind
I'm trying to get results from a MySQL database (for invoices) that includes multiple

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.