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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:35:20+00:00 2026-06-11T18:35:20+00:00

This is a little similar to Getting date list in a range in PostgreSQL

  • 0

This is a little similar to Getting date list in a range in PostgreSQL, but not exactly the same (I think).

I have a SQL table where every row contains a start and end date. I would like to form a query so that for each row, for each date inside this range, I get one result.

For example: id=1, title=MyRange, start=2012-08-05, end=2012-08-08

Query: SELECT * FROM myTyble where id=1 AND ...

Result:

 id=1, title=MyRange, date=2012-08-05
 id=1, title=MyRange, date=2012-08-06
 id=1, title=MyRange, date=2012-08-07
 id=1, title=MyRange, date=2012-08-08

I realize that unique and primary key rows will be duplicated in this result set, but that does not matter for me. Any ideas would be very welcome!

  • 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-11T18:35:22+00:00Added an answer on June 11, 2026 at 6:35 pm

    You can join to generate_series just as easily as you select from it. Something like this should do the trick:

    select t.*
    from generate_series('2010-01-01'::timestamp, '2013-01-01'::timestamp, '1 day') as s(d)
    join your_table t on (s.d between t.start and t.end)
    

    You’d supply the real dates you want instead of 2010-01-01 and 2013-01-01 of course.

    Older versions, such 8.3, don’t have a generate_series that works with timestamps but you can fake it by using generate_series to produce day offsets from an initial date:

    select t.*
    from generate_series(0, 1096) dt(d)
    join your_table t on ('2010-01-01'::date + dt.d between t.start and t.end)
    

    As before, adjust the 0, 1096, and '2010-01-01' to match your data.

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

Sidebar

Related Questions

First off, fairly new to JS but getting better :-) This question is similar
Maybe this is very basic, but I am all confused. I have a simple
Firstly I want to say I know little english. I have seeking about this
I have a scenario I'm getting a little muddled with using EF code first.
This is a task I have and I am a little unsure about the
I have a form that looks similar to this - <Form (Unique Form ID)
I know this question has been asked before, but I've had little success even
hopefully there's an easy solution to this one. I have my MVC2 project which
First off, I'll admit I'm cargo-culting this a little bit -- my nice clean
I am getting a 'case expression not constant' error in a switch statement. However,

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.