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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:44:22+00:00 2026-06-18T11:44:22+00:00

I have a table with following columns: ID startdate enddate I want the rows

  • 0

I have a table with following columns:

ID startdate enddate

I want the rows of this table to be repeated as many times as the difference between startdate and enddate along with a column which gives all the dates between these two days for each id in the table. So, my new table should be like this:

ID Date

A startdate
A startdate +1 day
A startdate +2 days (till enddate)
B startdate
B startdate + 1 day ....

Please note that I have different start and end dates for different IDs.

I tried the answer for the following question, but this doesn’t work:

Mysql select multiple rows based on one row related date range

  • 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-18T11:44:23+00:00Added an answer on June 18, 2026 at 11:44 am

    You need a numbers table… create a temporary table or dummy table that contains the numbers 1 to X (X being the maximum possible difference between the two dates)

    Then join to that table using a date diff

    I’m afraid I’m SQL Server and so not sure if the datediff functions work the same way in mysql, but you should get the idea.

    SELECT
        DateTable.Id,
        DATEADD(dd, NumbersTable.Number, DateTable.StartDate)
    FROM
        DateTable
    INNER JOIN
        NumbersTable
    ON
        DATEADD(dd, NumbersTable.Number, DateTable.StartDate) <= DateTable.EndDate
    ORDER BY
        DateTable.Id,
        DATEADD(dd, NumbersTable.Number, DateTable.StartDate)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a event table that has the following columns: StartDate datetime EndDate datetime
I have a table with the following columns: EntityId, EntityName, EntityProfile, ................. I want
I have the following table with the following columns: Person(id, name, surname) I want
If I have 2 date columns in a table, startDate and endDate . How
I have a table with 500,000+ rows and the following columns: Symbol , ExternalCode
I have a table which contains the following columns: UniqueID remote_ip_addr platform I want
I have a table with the following columns: a|b|c|d|e and I want to select
I have a table with the following columns: ref_year, ref_no, inv_id, start_date, end_date The
I have a table called tblRentalRates with the following columns: rate_id (int) rate_startdate (datetime)
Lets say I have table with following columns 1. Client - string. 2. Profit

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.