DateTime serialization best practices in NET 3 5

0 votes

Some years ago, I had followed this MSDN article on DateTime usage best practices for building a .Net client on .Net 1.1 and ASMX web services, with SQL 2000 server as the backend. I can still remember all the serialization issues I had with DateTime and the testing effort it took for servers across different time zones.

Does anyone know of any similar best practices document available for new technologies like WCF and SQL server 2008, especially with the addition of new datetime types for storing time zone aware info.

Environment:
1. SQL server 2008 on Pacific Time.
2. Web Services layer on a different time zone.
3. Clients could be using .Net 2.0 or .Net 3.5 on different time zones. (But, if it makes it any easy, we can just force everyone to upgrade to .Net 3.5.)

Any good suggestions/best practices for the data types to be used in each layer?

Dec 17, 2018 in Database by Bharani
• 4,620 points
200 views

1 answer to this question.

0 votes
One of the best ways to do this is by always passing the object as UTC, and converting to local time on the clients' side. That way, there is a common reference point for all clients.
You can call ToUniversalTime on the DateTime object for converting it to UTC. Then, when on the clients, just call ToLocalTime to get it in their respective current time zone.

Note: Clients will receive the datetime kind as Unspecified. So, doing DateTime.SpecifyKind(myUtcTime, DateTimeKind.Utc) instead of ToUniversalTime could be a better approach.
answered Dec 17, 2018 by DataKing99
• 8,240 points

Related Questions In Database

0 votes
1 answer

My values in my codes aren't inserted into mySQL. I input 5 but it will show 0. Any ideas?

Hello, You can refer my corresponding sample web ...READ MORE

answered Jul 13, 2020 in Database by Niroj
• 82,720 points
151 views
0 votes
1 answer

Database Repair Options in Cassandra

Anti Entropy: Anti-entropy Repair is a process of ...READ MORE

answered Jun 28, 2018 in Database by kurt_cobain
• 9,390 points
900 views
0 votes
1 answer

Logging Levels in Cassandra

ALL: All levels including custom levels TRACE: Designates finer-grained informational ...READ MORE

answered Jun 28, 2018 in Database by shams
• 3,660 points
140 views
0 votes
2 answers

Durable Writes in Cassandra

When Cassandra write: 1. memtable (in memory) 2. commit ...READ MORE

answered Nov 25, 2018 in Database by Amit
• 180 points
4,315 views
0 votes
1 answer

How to convert datetime.date to UTC timestamp in Python

In Python 3 (< 3.3) From the docs ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 58,120 points
8,155 views
0 votes
1 answer

Using unserialize in PHP throws the same error repeatedly

I googled 'Node no longer exists', and ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
550 views
0 votes
1 answer

python 'x days ago' to datetime

You just need a timedelta and try ...READ MORE

answered Feb 26, 2019 in Python by SDeb
• 13,270 points
1,771 views
0 votes
0 answers
0 votes
1 answer

Indexes in Database

The index is a data structure that ...READ MORE

answered Aug 20, 2018 in Database by DataKing99
• 8,240 points
218 views
0 votes
1 answer

Atomicity and Aggregation in Database

Atomicity is the condition where either all the ...READ MORE

answered Aug 22, 2018 in Database by DataKing99
• 8,240 points
721 views