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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:39+00:00 2026-06-03T22:31:39+00:00

I’ve been Googling for a while now trying to find some sort of solution

  • 0

I’ve been Googling for a while now trying to find some sort of solution to this but have had little luck.

I’m trying to get a set of records that corresponds to a single day’s worth of data. A single day’s worth of data is 4:00:00EST-3:59:59EST. When I display my set of results to the user I would like the results to be displayed in the user’s local time (in my case CST). This wouldn’t normally be all that hard except:

  • The timestamps in my database are all in GMT.
  • The local time of the database is in EST.
  • My local time is CST.

Since the database’s time is in EST but the records are saved in GMT I can’t simply call GETDATE() and adjust it.

It’s also worth noting that I’m using LINQ/Entity Framework 4.1 Code-First in C# and database I’m hitting is Sybase.

So, what would be a solid way for me to convert the data from GMT to the user’s local time given the information above?

  • 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-03T22:31:40+00:00Added an answer on June 3, 2026 at 10:31 pm

    It turns out that I was overthinking this quite a bit and the solution is actually quite simple. The following links were extremely helpful:

    http://iamacamera.org/default.aspx?section=develop/code%20snippets&id=76
    http://msdn.microsoft.com/en-us/library/ms973825.aspx

    Before querying the database I set the following variables:

    DateTime utcBeginDateTime = DateTime.UtcNow.Date.AddHours(8);
    DateTime utcEndDateTime = utcBeginDateTime.AddDays(1);
    

    Which gives me UTC time of 5/10/2012 8:00:00 AM to 5/11/2012 8:00:00 AM. Converting this to EST is rather simple:

    TimeZoneInfo estZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
    DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(utcBeginDateTime, estZone);
    

    This will give me EST time of 5/10/2012 4:00:00 AM.


    Using this in my LINQ query:

    var timeQuery = from p in db.cl_contact_event
                    where p.time_of_contact >= utcBeginDateTime && p.time_of_contact < utcEndDateTime
                    select new
                    {
                        time = TimeZoneInfo.ConvertTimeFromUtc(p.time_of_contact.Value, estZone),
                        id = p.id
                    };
    

    It’s worth nothing that TimeZoneInfo.ConvertTimeFromUtc() will probably not work unless you run the query on the client using .AsEnumerable(). I know it definitely doesn’t work with our version of Sybase. Thus, I’m forced to filter the results as much as I can, call .AsEnumerable(), and then do the time zone conversion/other logic.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.