|
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
|
|
|
|
|
MS Access won't accept milliseconds, so you have to do ToString() on all dates going into a date-type field
dateOfEntry = DateTime.UtcNow.ToString(); which removes the milliseconds.
|
|
|
|
|
I don't, but perhaps you should hold your end of the bargain and not go sleep when downloading updates.
An update that should've been done in an hour took all morning and a good chunk of my Saturday afternoon. Because it's freakin' Saturday, and I want need to walk away, so the computer repeatedly goes to sleep.
And people wonder why I configure my systems so they never go to sleep...except for this one. But it's about to join that club.
|
|
|
|
|
dandy72 wrote: they never go to sleep
That's usually the first setting I change with the exception of laptop but only when unplugged. At least set it (sleep) for a few hours.
"Go forth into the source" - Neal Morse
|
|
|
|
|
|
That windbreaker is causing a lot of drag.
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
|
|
|
|
|
The answer my friend, is blow blow blowing in the wind
|
|
|
|
|
|
|
|
Update: Looks like that's fixed it, for the moment.[^]
It hadn't. So ... I bit the bullet and got a replacement part.
It's the micro USB connector, the PCB that's located on,, the headphone connector and its mounted to, a flexi PCB between them, and a dinky little 22pin, 0.5mm spacing, locking ribbon connector which attaches it to the main board.
All you have to do is open the tablet, disconnect the battery, undo three screws, move the speakers out of the way, undo five more screws, open the latch, remove the connector PCB(s), fit the new one, close the latch, replace the screws, replace the speakers, replace the three screws that hold that, reconnect the battery, and push the back back on.
Tools: tiny phillips screwdriver, tiny flat head screwdriver (for the latch), plastic thing what takes the back off.
Total time: under ten minutes.
Total cost? £3.50 for the bit, £1 for the plastic thing what takes the back off (which is probably not reusable, they are cheap plastic). Screwdrivers I have in abundance.
Full charge from empty in a couple of hours (using my 2A charger).
That'll do, that'll do ...
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Truth time: how many parts were left over after you put it back together?
Message Signature
(Click to edit ->)
|
|
|
|
|
Just the old bit I replaced.
I learned at a young age that when you dismantle something, you take care to ensure there isn't anything left over with motorcycle engines. The main reminder was the gear change return spring incident where I discovered that going up the gears was fine without it, but you couldn't go back down. And that included neutral, sod it.
I don't like to make the same mistake twice
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Experience: Recognizing a mistake the second time you make it.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
What bike Paul ?
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|