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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:39:41+00:00 2026-05-11T20:39:41+00:00

I need to work out how many different instances occur on a different day,

  • 0

I need to work out how many different instances occur on a different day, from many different ranges. Probably best to explain it with an example.

18-JAN-09 to 21-JAN-09
19-JAN09 to 20-JAN-09
20-JAN-09 to 20-JAN-09

Using the three examples above, I need it to collect this information and display something a little like…

18th Jan: 1
19th Jan: 2
20th Jan: 3
21st Jan: 1

… I’ll be grabbing the information from an Oracle database fwiw (hence the format above ^) and there will be hundreds, maybe thousands of records, so my lame attempt to do all sorts of loops and if statements would take forever to run.

Is there any fairly simple and efficient way of doing this? I’m really not too sure where to start unfortunately…

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-11T20:39:41+00:00Added an answer on May 11, 2026 at 8:39 pm

    Either your DB engine or your PHP code is going to have to loop over the date range.

    Here’s some PHP code to do the summation. The day counts are stored by year-month to avoid having a huge array for a wide date range.

    <?php
    
    // Get the date ranges from the database, hardcoded for example
    $dateRanges[0][0] = mktime(0, 0, 0, 1, 18, 2009);
    $dateRanges[0][1] = mktime(0, 0, 0, 1, 21, 2009);
    $dateRanges[1][0] = mktime(0, 0, 0, 1, 19, 2009);
    $dateRanges[1][1] = mktime(0, 0, 0, 1, 20, 2009);
    $dateRanges[2][0] = mktime(0, 0, 0, 1, 20, 2009);
    $dateRanges[2][1] = mktime(0, 0, 0, 1, 20, 2009);
    
    for ($rangeIndex = 0; $rangeIndex < sizeof($dateRanges); $rangeIndex++)
    {
      $startDate = $dateRanges[$rangeIndex][0];
      $endDate = $dateRanges[$rangeIndex][1];
    
      // Add 60 x 60 x 24 = 86400 seconds for each day
      for ($thisDate = $startDate; $thisDate <= $endDate; $thisDate += 86400)
      {
        $yearMonth = date("Y-m", $thisDate);
        $day = date("d", $thisDate);
    
        // Store the count by year-month, then by day
        $months[$yearMonth][$day]++;
      }
    }
    
    foreach ($months as $yearMonth => $dayCounts)
    {
      foreach ($dayCounts as $dayNumber => $dayCount)
      {
        echo $yearMonth . "-" . $dayNumber . ": " . $dayCount . "<br>";
      }
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to work with array from several threads, so I use CRITICAL SECTION
I need my program to work only with certain USB Flash drives (from a
I need to work with MSMQ (Microsoft Message Queuing). What is it, what is
Every time I need to work with date and/or timstamps in Java I always
I am a Java programmer and need to work on a Flex/ActionScript project right
I have a situation where I need to work with a datagrid and adding
For my work I need to create a Autorun application for a CD for
I need to do some work with a backup WSS .dat file and I'm
I'm work in an aplication that need be capable of support plugins, but i
Well behaved windows programs need to allow users to save their work when they

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.