|
|
Would you send your kids out trick-or-treating this year?
If you do, how have you told you kids to behave if they hear coughing and heavy breathing through the door before it is being opened?
|
|
|
|
|
Since my kids have kids in college (or graduated from same), they are on their own.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
What if your neighbour, with small kids, come and ask you: Both mom and dad have been called to meetings that they cannot reject, so do you have any chance of following the kids around as a guardian?
Or, if your grandchildren were old enough to have children, would you think a great idea to send your great-grandchildren out trick-or-treating?
OK, so for you, it is a hypothetical situation (so it is for me!), but I think we should be able to relate to the question.
|
|
|
|
|
Just as I don't plan to answer any knocks on the door, I would not accompany any kids around. Bad idea. (I am old enough to be at risk). Besides, I am the mean old curmudgeon on the block.
The reality is, this neighborhood has very few small children and each year we eat our own candy.
What if there were no hypothetical questions?
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
I think it's... SMOOOOOKIN'!
|
|
|
|
|
|
|
What's worse, that, or using varchar to store numeric values?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Using VARCHAR to store dates...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Funny enough, this happened to me a couple of weeks ago...must have been a typo in a create table statement from long ago as there is no trace of it now. I was about to pull my hair out when a query with a filter on that 'date' kept giving me 'incorrect' results.??? Sorting wasn't working right either. Luckily, I found it before the client did.
"Go forth into the source" - Neal Morse
|
|
|
|
|
I found that just two weeks ago!
Imagine my surprise when I entered some text and it crashed on a cast during runtime
What's worse, it was supposed to be a foreign key constraint, but instead the developer used that varchar field to store a smallint in another table and then did an if then else on the smallint to show an actual text
|
|
|
|
|
Why's everyone in this cartoon naked?
|
|
|
|
|
It's the naked truth!
|
|
|
|
|
I hadn't even noticed
|
|
|
|
|
I'm now working with Julian. (dates stored as int) Obviously it's easy enough to dateadd it, but still a pita. Why someone would choose Julian is beyond me...possibly better query performance?
"Go forth into the source" - Neal Morse
|
|
|
|
|
As in the Julian calendar?
Only Julian I know, but never worked with it because who the hell uses that?
|
|
|
|
|
No, Julian days (abbreviated JD) are based on a fixed origin (noon Jan 1st 4713BC) and counting from there. There are variants like "modified Julian day" (MJD) or "reduced Julian day" (RJD).
There is a whole article on Wikipedia: Julian day - Wikipedia[^]
Mircea
|
|
|
|
|
Mircea Neacsu wrote: (noon Jan 1st 4713BC) Is that the day when the world was created?
|
|
|
|
|
No, that's Fred's birthday
Seriously, it's a number related to some super large astronomical cycle. Astronomers decided on it a few hundred years ago and, as origin is arbitrary, it stayed like that. For details see:Julian day | Calendar Wiki | Fandom[^]
Mircea
|
|
|
|
|
But didn't all those different astronomical cycles start from zero when the world was created?
|
|
|
|
|
kmoorevs wrote: Why someone would choose Julian is beyond me
Either they're working for the orthodox church, living in the autonomous province of Mount Athos or they just f***ed up.
Possibly all three at the same time.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
I apologize if I'm too dense or too nerdy: I don't see anything intrinsically wrong with storing a date as a float.
A 4-byte float value has 3 bytes for mantissa giving 2^24 values that can be correctly represented. That makes almost 17 million days or almost 46000 years. I'd argue that this is decent range for most general purpose applications.
It might be unusual or not keeping with established rules, but is not breaking any (computer) law.
Mircea
|
|
|
|
|
It's simply not a date, and every time you'll have to use it you either need to cast it to a date (performance bottleneck) or you need to know exactly how it's formatted, etc.
It'll also be a matter of time before you get 20201005.00000000003 because it's still floating point arithmetic.
Or perhaps someone will enter 1 or 2020931, who'll say as there are no validations.
I'm now assuming the format of yyyyMMdd, but maybe it'll be days since [some date], like JavaScript and Linux do.
Perhaps people will use a local date, such as 05102020 or 10052020, good luck working with that.
Now let's say the float contains ISO dates in the form of yyyyMMdd and the date is 20201029, now add 7 days, good luck!
All in all, it's a lot of trouble, ambiguity and simply disaster waiting to happen.
If you really need dates that do not fit into any SQL date type, use separate integers for year, month and day, I guess.
|
|
|
|
|
Quote: I'm now assuming the format of yyyyMMdd
I see, you are talking about those dates, with random number of days in the month. Sorry, but in that case the cartoon bubble should have said "Officer, he is using vaguely defined dates!", and yes, that should be a punishable offense.
The only well-defined timestamps are those based on a definition like "the number of <somethings> from <origin>". In case of dates can be "number of days from noon, Jan 1st of 4713BC" (Julian date) or "number of days from midninght, Jan 1st, 1970" (Unix time). Notice that in this case fractional parts have a natural meaning (fractions of a day). For good measure, don't forget to add a meridian so we know exactly what "midnight" means.
Mircea
|
|
|
|