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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:34:31+00:00 2026-05-12T19:34:31+00:00

I have a problem for querying records into mysql explanation below The user could

  • 0

I have a problem for querying records into mysql

explanation below
The user could pick a date to assign in variable fromdate and todate

example.

$fromdate = 2008/01/01
$todate = 2009/10/31

In above case, i have to loop and query with the ff:

SELECT * FROM table where date BETWEEN '2008/01/01' AND '2008/12/31';

second loop

SELECT * FROM table where date BETWEEN '2009/01/01' AND '2009/10/31';

if $fromdate and $todate is more than one year then I have to limit my query per year. But if less than one year then use $fromdate and $todate in the query.

Thanks in advance

Tirso

  • 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-12T19:34:31+00:00Added an answer on May 12, 2026 at 7:34 pm

    You can use something like this to calculate the date.

    $d1 = new DateTime($todate);
    $d2 = new DateTime($fromdate);
    $d2->modify("+1 year");
    $min = min($d1, $d2);
    $todate = $min->format('Y/m/d');
    

    If you want to paginate the results, you will have to modify $fromdate on each page before doing the $todate calculation. For example, if you are on the second page, first load $fromdate into a DateTime object and add one year, if you are on the third page, add two years, etc.

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

Sidebar

Related Questions

Hi I have an issue on querying for subsecond accuracy queries from GQL.. Wondering
I have two tables that I'm querying from. In one table, there are fields
I have no problem using linq to xml to query xml but I have
Hi I experience a strange phenomena. I have a Java application that queries DB
i have an application where i order make a query to my database with
I'm in the process of learning Prolog. I have this recursive predicate: add(0,Y,Y). add(succ(X),Y,succ(Z))
I was hoping to implement an easy, but effective text search for App Engine
I am working with a web site analyser which will be used to analyse
I'm stumped on this one, or just to late at night to be thinking
I rewrite application from ASP.NET to Silverlight and use NHibernate 2. Tables in my

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.