Weekly Challenge: DateTime in C#

8
2



Challenge Page (with solution):

Practice makes perfect, right? Well, mostly, but practice is very important. This series is all about getting you to practice the things you learn. I would encourage you to do every one. See which ones are just easy refreshers and which ones are difficult learning experiences.

Nguồn:https://wijstaanvooronzegrondrechten.org/

8 COMMENTS

  1. Sir, please help me if you can…
    My problwm is that i have prepared a database application in c# windows..all is well but there are two problem annoying me.
    1- is all the form in application in working well except 4 forms are taking long time in opening.
    2 – is my OS was windows 10 with vs2015 community with update 3…my appliction was running well on my pc and on client pc but at this time my os has changed to win7…application is workin on my pc with win7 but not workin on client pc with win 10… error is the "conversion of varchar data type to date time resulting an out of range value" what cause this to me….

  2. Both my remaining ancient silver-haired brain cells had to work overtime to complete the bonus challenge for this one. Got there in the end! Well, my version that is.

  3. I have a challenge for you as well.
    Can you safely store C# DateTime milliseconds in SQL Server's DATETIME?
    Can you safely store C# DateTime's ticks as a number in JavaScript?
    (click read more to reveal answers)

    No. While SQL Server's DATETIME has precision of milliseconds, the las digit can be only 0, 3, or 7. (Use DATETIME2 instead)
    No. JS number's maximum precise integer is 2^53 (29 A.D.), while 2^59 is 1827 A.D. But you can store total number of milliseconds because 9999 A.D. in milliseconds is less than 2^49.

  4. If you are using a DB to persist time…then 1) convert to UTC before saving AND 2) convert ToLocal when retrieving. You never know how many time zones your app will be ran in NOR the time zone of the DB server(this may change as well).

LEAVE A REPLY

Please enter your comment!
Please enter your name here