|
Thanks! I was surprised though, I really thought another article would win (can't find the link to it right now, sigh)
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
NOBODY is smarter than you!
Keep your friends close. Keep Kill your enemies closer.
The End
|
|
|
|
|
S'truth !
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
R. Giskard Reventlov wrote: NOBODY is smarter than you!
Hah! I'm smart enough to know that's not true.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Marc Clifton wrote: I'm smart enough to know that's not true. This is called modesty in my town
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I am the wisest man alive, for I know one thing, and that is that I know nothing. ~Socrates
|
|
|
|
|
I'm afraid I'm not that pedantic with my timesheet - 1 second either way is just fine by me <snicker>.
Seriously 1 second difference in a timekeeping system, way too precise. The only system I worked on measured in 15 minute blocks.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: measured in 15 minute blocks.
Exactly
|
|
|
|
|
So how does your boss know you're not clocking out at 7:59:59?
|
|
|
|
|
Boss does not care!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Seriously 1 second difference in a timekeeping system, way too precise.
I agree, but I wanted to start with precision down to the second and let my client decide if his customers would want a more granular precision and then go from there.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Ah commercial software, the place where you need to cater for the silliest requirements because some pillock of a salesman will try and sell it as a benefit.
Ah commercial software where you cannot tell the user they are complete idiots because their requirements make no sense in the real world.
2 reasons I went to corporate development all those years ago (and the money was good).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: pillock of a salesman
Isn't this redundantly redundant?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
True but calling them just salesmen does not convey my sentiment towards them.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi, I've been using the code on the post on that same SO thread you mention that makes use of TimeSpan.TicksPerSecond and other TimeSpan values to truncate to several different values:[^]
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Oooh, that one is even better! Thanks!
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Marc Clifton wrote: ...MM/dd/yyyy HH:mm:ss tt (for us US people).
You f***en weirdos.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
|
Slacker007 wrote: Try storing your date times as DATETIME2 in the database, if SQL Server.
Also good to know. More learning.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
Slacker is right in my opinion.
You should always use Datetime2 for new work[^]. It's not just having better compatibility with other databases. But also with DateTime in .Net.
If you change datatype in the db to DateTime2(0), the fractional seconds are automatically stripped, and the problem is solved.
|
|
|
|
|
Marc Clifton wrote: new DateTime(date.Ticks - (date.Ticks % resolution), date.Kind);
Is that is going to work if they work from 12:00 midnight to 8 am when daylight savings time switches?
|
|
|
|
|
Ha, thats easy, you want to store some timestamps.
Ill use DateTime.Now. to string().
gets me 01/02/2018 11:58:00
Ah good.
next day. F***. Person installed on server, and language in american. I dont know which is month and day.
fix: DateTime.Now.toString("DD/MM/YYYY hh:mm:ss")
next day. F***. the time is in 12 hour format and says I only did 1 hour of work yesterday.
fix: DateTime.Now.toString("DD/MM/YYYY HH:mm:ss")
add some uses case tests.
next day. it still works. good.
2 months later. deployed to 100 clients.
next day. All times off by 1 hour (DST). FFS
|
|
|
|
|
jschell wrote: Is that is going to work if they work from 12:00 midnight to 8 am when daylight savings time switches?
Good point. I totally forgot about that. Fixed now. My client should pay you for pointing that out.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
I once worked for 36 hours straight. Are you telling me that I'm not getting paid for all of it?
|
|
|
|
|
I would assume this is a simple rounding problem. But not where you expect it but in the internals of DateTime. Historically, DateTime is a double and not a "long long". Dates and times are converted to and from that double. One day is 1, half a day 0.5 and so on. And as it goes with the digits after the decimal point you can not represent any small fractions with a limited number length. Imagine a day has about 10e5 seconds or 10e8 ms. Adding the day (I don't remember when the counting starts) with 5 digits you are using 13 out of 15 digits. A millisecond is 1,157407407407e-8 days.
For testing you can write a routine which start at "Now" and adds millisecond after millisecond. Be surprised what you get when you expect a steady increasing value.
See also https://en.wikipedia.org/wiki/System_time
|
|
|
|