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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:30:54+00:00 2026-05-25T09:30:54+00:00

I have an older sql 2005 box, and I need to do some summaries

  • 0

I have an older sql 2005 box, and I need to do some summaries of a table with ~500m rows.

I have a datetime column in the table and I want to get just the date out of it for output and group by. I know there are a few ways to do this, but what is the absolute fastest?

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-05-25T09:30:55+00:00Added an answer on May 25, 2026 at 9:30 am

    I suspect the fastest would be to:

    SELECT
      the_day = DATEADD(DAY, the_day, '19000101'), 
      the_count
    FROM
    (
      SELECT 
        the_day = DATEDIFF(DAY, '19000101', [the_datetime_column]), 
        the_count = COUNT(*)
      FROM dbo.the_table
      GROUP BY DATEDIFF(DAY, '19000101', [the_datetime_column])
      WHERE ...
    ) AS x;
    

    But “fastest” is relative here, and it will depend largely on the indexes on the table, how you’re filtering out rows, etc. You will want to test this against other typical date truncation methods, such as CONVERT(CHAR(8), [the_datetime_column], 112).

    What you could consider – depending on whether this query is more important than write performance – is adding a persisted computed column with an index, or an indexed view, that would help this aggregation for you at write time instead of query time.

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

Sidebar

Related Questions

I have some SQL I need to get working on SQL 2005/2008. The SQL
SQL 2005, I have a table with a column 'ages_c', I need to group
I'm using Sql-Server 2005 I have Users table with userID and gender. I want
I have some (untyped) XML being stored in SQL Server 2005 that I need
I'm running SQL Server 2005 and .Net 2.0. I have some tables that need
In SQL Server 2005, I have an order details table with an order id
I'm trying to store XML in SQL 2005. I have a very simple table
I have a SQL 2005 table consisting of around 10million records (dbo.Logs). I have
I have a sql server 2005 table called ZipCode, which has all the US
in my SQL Server 2005 database I have a column RMA_Number with datatype char(10)

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.