Local Time & UTC Confusion C#, SQL Server - sql

I am storing all dates to SQL Server as a UTC date time. I have Time Zone Id for each user stored in user profile as well.
Now when user requests data back, I want to display local time of user for each record using the Time Zone I have stored in profile for the particular user.
What is an easiest and optimized way (as I am processing heaps of records at the same time) to convert all dates and time to particular time zone on the fly while returning data? Either in SQL or in C# would be fine...
Very important question is, let's say there is a record created from Sydney when there was Day Light Saving "ON" and now Day Light Saving is "OFF". As the record was created when Day Light Saving was "ON", will it still convert the same time or will it return conversion as per current time zone status (which is Day Light Saving is "OFF")???
People only see those records which they had created from the particular

let's say there is a record created from Sydney when there was Day Light Saving "ON" and now Day Light Saving is "OFF". As the record was created when Day Light Saving was "ON", will it still convert the same time or will it return conversion as per current time zone status (which is Day Light Saving is "OFF")
The record contains an UTC date and time. This is going to fall into a DST ON or DST OFF period, deterministic. Is irrelevant whether the DST is in effect now. The opposite (storing local time, trying to extract UTC) is undetermined because of the overlap times when the DST changes (a small range of local times cannot be deterministically converted to UTC if they fall into the 60 mins that occurs twice when DST come into effect, assuming a 60 min DST).
As for the question: transform the date in your presentation layer. Use TimeZoneInfo.ConvertTimeFromUtc.

Related

Set automatic date and time in json using kql or anything

I have a json object and in that I have date and time and want that date and time to be set automatically meaning it should read computer's date and time automatically every day when the application is in run? Can anyone help how to do that?
I don't have any solution for this.

Query table based on users local hour, rather than GMT hour (including daylight savings support)

If users want notifications or certain activities triggered based on an hour of the day in their local timezone. You could store each users preferred notification hour in the database, and just poll the table every hour for who wants a notification. But this won't take daylight savings into account. How is this normally solved?
Assuming the user requests 9am EST:
If you convert 9am EST to GMT, and store the GMT hour in the database. This doesn't work, because that GMT conversion is only valid until daylight savings time.
If you store 9am EST directly in the table, then you have to query every single row in the table including their timezone and calculate the current time in every row.
Option 2 works, but only for a small database. What is the best way to do this?
One option would be to store the hour in GMT, so you can batch/segment the table into 9am, 10am, etc...
Then, every time you do a notification, you recalculate tomorrows time, so that the day before Daylight Savings, not only will the notification be sent, but the hour will be updated in preparation for tomorrow.
The only catch to this solution is that if you have a large segment (i.e. US), then there will be a large bulk update occurring on certain days of the year.

Daylight saving with historical reporting data

TL;DR Is there a simple way to handle daylight saving timezone for historical data ?
We have a list of timezone along with thier offset to UTC which is changed for certain zones as per DST timings. All the data is stored in UTC but displayed as per the user timezone. The issue is when DST is active or reverted the historical data view also changes . This creates a discrepancy in customer reporting in terms of billing and order counts.
Is there a standard way of handling this ?

How to find day light time saving is active and save time in SQL for UK?

I am looking to save current UK time and problem is they have two timezone GMT and BST accordingly day saving light ?
I am saving time in SQL date time column from mobile app and SQL server. I am insert time using SQL.

Getting data using mirth by schedule

I need get patients data every day several times - in 9 am, 12 pm and 3 pm.
Where I can setup this in Mirth?
I looked to chanel setup, but do not find any acceptable.
The setting lies in the source tab of the channel setup. Assuming your channel source connector is Database reader or a file reader.
Set the Polling type as Time instead of interval. That will ask you to specify a particular day time eg 11:15 AM and everyday at that time the data will be polled.
If you are talking about 3 hours gap then set the polling type as interval and put the value of 108000 ms(1000*6*6*3) in polling frequency.