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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:36:43+00:00 2026-06-05T04:36:43+00:00

I have data in Microsoft SQL Server 2008 that I need to SUM. The

  • 0

I have data in Microsoft SQL Server 2008 that I need to SUM. The catch is I need to group the sums by a 24 hour period. The 24 hour period is from 3:00pm one day to 3:00pm the next day.

For Example

DateExited, Value

1/1/2012 15:00, 5

1/1/2012 15:04, 6

1/1/2012 17:00, 7

1/2/2012 00:00, -5

1/2/2012 09:00, 10

1/2/2012 15:00, 31

The sum of that should be 54. I have the following query but that groups everything from midnight to midnight instead of 3:00 pm to 3:00 pm

SELECT dateadd(day,datediff(day,0, dateadd(hh, 0, DateExited) ),0) As SummaryDate, SUM(Value) as s1
FROM Test
where DateExited BETWEEN dateadd(year,datediff(year,0,GETDATE()),0) AND GetDate()
GROUP BY dateadd(day,datediff(day,0, dateadd(hh, 0, DateExited) ),0)
ORDER BY SummaryDate
  • 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-05T04:36:46+00:00Added an answer on June 5, 2026 at 4:36 am

    You could add minus 15 hours, and then cast the result to date:

    select  cast(dateadd(hour,-15,'2012-05-06 14:30') as date) -- 2012-05-05
    select  cast(dateadd(hour,-15,'2012-05-06 15:30') as date) -- 2012-05-06
    

    Giving you a group by like:

    group by cast(dateadd(hour,-15,'2012-05-06 03:30') as date)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Microsoft SQL Server 2008 query that returns data from three tables
I have a Microsoft SQL server DB that imports some data which needs a
(ANSWER) How to export some Geography data from a Microsoft Sql Server 2008. You'll
I have a website using Microsoft SQL 2008 server over local network. Sometimes, SQL
I have a database called MyDB in a Microsoft SQL Server 2008 Express instance
I have a table with 300 million rows in Microsoft SQL Server 2008 R2.
I am attempting to connect to Microsoft SQL Server 2008 R2 from within Microsoft
I am using playframework with a legacy SQL Server 2008 database that has data
I have a MySQL server as a linked server in Microsoft SQL Server 2008.
Here's the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM

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.