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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:18:38+00:00 2026-05-12T07:18:38+00:00

I have a continous time dataset and I want to break it up into

  • 0

I have a continous time dataset and I want to break it up into 15 minute blocks using sql.

I don’t want to have to create a new table to be able to do this if I can help it.

i.e.

Time, Count

09:15, 1

09:30, 3

09:45, 0

10:00, 2

10:15, 3

…..

Does anyone have any idea of how I can do this. I presume that is use a select similar to the following:

SELECT [Some kind of data manipulation on “MyDate”]

, COUNT(ID)

FROM MyTable

GROUP BY [Some kind of data manipulation on “MyDate”]

  • 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-12T07:18:38+00:00Added an answer on May 12, 2026 at 7:18 am

    With careful use of dateadd and datediff, this can be accomplished. My solution rounds the times down.

    The first piece calculates the number of minutes between the row’s date and the epoch (0) and does a mod 15 on it, giving the difference between the row’s date and the closest 15 minute interval:

    select -1 * datediff(minute, 0, mydate) % 15
    from mytable
    

    Next, we need to deal with just the minutes, so we use this date-part stripping technique I learned from SQL Server Magazine February 2007 (Datetime Calculations by Itzik Ben-Gan):

    select dateadd(minute, datediff(minute, 0, mydate), 0)
    from mytable
    

    Then, we add the difference to the row’s date column and group and count and voila!

    select dateadd(minute, -1 * datediff(minute, 0, mydate) % 15, dateadd(minute, datediff(minute, 0, mydate), 0)), count(ID)
    from mytable
    group by dateadd(minute, -1 * datediff(minute, 0, mydate) % 15, dateadd(minute, datediff(minute, 0, mydate), 0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have been using Teamcity for some time for the Continous Integration in the
I have no rails environment but I want to use cruisecontrol.rb as my Continous
Im using the jQuery SmoothDivScroll plugin. http://www.smoothdivscroll.com/ I want to have continuous scrolling, but
I have setup a Continuous Integration environment using CruiseControl.Net. I want to know how
I have a continous process that collects data, and I want to write the
I want to have a continuous Cell, which is not cropped to the width
We have Xserver-less CentOS system for continuous integration. So no UI. I want to
We are using Teamcity to do continuous integration builds for our website and have
Suppose I have a sequence x1,x2,x3.....xn, and I want to find the longest continuous
i have a directory with around 1000 files....i want to run a same code

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.