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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:10:57+00:00 2026-05-28T19:10:57+00:00

I have a linq-to-sql query that groups results by DateTime, something like this: var

  • 0

I have a linq-to-sql query that groups results by DateTime, something like this:

var TheQuery = from ....
               where ....
               group a by a.TheDateTime.Date in TheGroups

The problem is that this groups by actual dates that are stored in UTC in the DB. Let’s say that I want to group by dates based on the user’s timezone. So for instance, if he’s in the PST timezone, group by “UTC minus 8 hours”, or whatever other offset.

Thanks for your suggestions.

  • 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-28T19:10:58+00:00Added an answer on May 28, 2026 at 7:10 pm

    If you’re getting all the information back anyway, I’d frankly bring it back to the client and do the grouping in LINQ to Objects. That way you can concentrate on using one platform’s date and time API – it’s hard enough using one API correctly when it comes to time zones, let alone two.

    (As an aside and a plug, it also means you can use whatever .NET API you like for this – such as Noda Time 😉

    So I’d put all the filtering and projection you can do before the grouping, then use AsEnumerable() to force the rest of the execution to occur locally.

    Don’t forget that you almost certainly can’t just add or subtract 8 hours, unless the user is really in a time zone which doesn’t use daylight saving time (and hasn’t historically). Are you also sure that it’s appropriate to apply the same time zone to all the data? (It may well – just checking.)

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

Sidebar

Related Questions

I have a LINQ from SQL query that returns sorted rows. For instance, it
I have a Linq to SQL query that was working just fine with SQL
I have a LINQ to SQL query that returns a grouped collection of Sponsor
I have one Linq to SQL query that simply joins three tables and then
I have a somewhat simple query in SQL that I would like to convert
I need to make a query that look like this is SQL: SELECT CodProiect,
I have this Linq to object query: var result = Users.Where(u => u.Address.Country.Code ==
Strange performance outcome, I have a LINQ to SQL query which uses several let
I have the following Linq to SQL query, in which I'm trying to do
I have a very simple linq to sql query in C#: int acctNum =

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.