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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:31:06+00:00 2026-06-05T12:31:06+00:00

So what I am trying to is generate all the hours that are inside

  • 0

So what I am trying to is generate all the hours that are inside a specific time range.

So given the range 11 AM to 2:00 PM, I would get:

 11:00 AM
 12:00 PM
 1:00 PM
 2:00 PM

I am trying to avoid having to store every specific hour a store might be open and just store the range (I need to compare the hours against other times)

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-05T12:31:08+00:00Added an answer on June 5, 2026 at 12:31 pm

    If you have a numbers table (click the link to create one if you don’t)…

    create table test(
        startTime time
    ,   endTime time
    )
    
    insert into test
    select '11:00', '14:00'
    
    select
        dateadd(hh, n.n, t.startTime) as times
    from test t
      inner join Numbers n
        -- assuming your numbers start at 1 rather than 0
        on n.n-1 <= datediff(hh, t.startTime, t.endTime)
    

    If this is specialized, you can create an hours table with just 24 values.

    create table HoursInADay(
        [hours] time not null
    ,   constraint PK_HoursInADay primary key ([hours])
    )
    
    -- insert
    insert into HoursInADay select '1:00'
    insert into HoursInADay select '2:00'
    insert into HoursInADay select '3:00'
    insert into HoursInADay select '4:00'
    insert into HoursInADay select '5:00'
    insert into HoursInADay select '6:00'
    insert into HoursInADay select '7:00'
    ...
    
    select
        h.[hours]
    from test t
      inner join HoursInADay h
        on h.[hours] between t.startTime and t.endTime
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to generate a query that selects all from a user table
I'm trying to generate all possible subsets for a specific bool vector of size
Given a DNA string for example AGC . I am trying to generate all
I am trying to generate a list of all possible number combinations within a
I am trying to generate a controller with all the RESTful actions stubbed. I
I'm trying to generate a report of the activities that users have done within
I've created domain class: grails create-domain-class Trip At now I'm trying: grails generate-all Trip
I am trying to figure how how to find all the combinations given the
I've looked around for hours trying to get this to work. I'm not new
I'm struggling for some hours now with this problem: I'm trying to get 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.