- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well, in the database I use, I would just pass the date and negative-two to the ADDMONTH() function. But who needs such niceties, when you've got a PHP god on your team?
And the "date" is varchar(5) because he's planned ahead for the "y2k+100 bug".
Admin
GOD DATE MANGLING!
That's almost what I would have exclaimed if I had to deal with this code.
Admin
So, if someone says he's as clever as god, all that really tells you is that he's not in the middle. He could just be stupid, or he really could be that smart.
Then again, stupidity is more common than that degree of intelligence, so it's not a bad assumption that a supposed "god" is probably stupid.
Admin
[quote user="bertram"][quote user="dguthurts"]SELECT <explicit list of fields>[/quote]
[quote] I love these people that just blindly repeat the claim that "SELECT *" is somehow evil, without any kind of understanding of whether is actually is, or why it could be.[/quote]
Not evil. As noted previously, lazy and not good practice
http://www.sql-server-performance.com/2001/sql-best-practices/
Admin
captcha: secundum = near instantaneous stupidity
Admin
Man are you ill-informed. The TIMESTAMP and DATETIME field types are stored using the same 'YYYY-MM-DD HH:MM:SS' format. There are two differences between them: 1) TIMESTAMPs are stored in UTC, but retrieved in the server's current timezone, and 2) TIMESTAMP has the 'ON UPDATE CURRENT_TIMESTAMP' event.
That said, if you really wanted to make your life more difficult, you would store integer times as UNSIGNED INT (or BIGINT, depending on how far into the future you wanted to store times). But, doing so would require convoluting your SQL queries to do date/time comparisons:
And that's just a simple example! Start throwing in the logic to compare months, years and days; with some DATE_ADD/DATE_SUB and whatever other business logic that you need, and you're just asking for a front-page WTF.
The right tool for the right job.
PS. You really should RTFM:
TIMESTAMP DATETIME
Admin
Admin
So what? $yearmonth passed in from the front end must be between xx03 and xx12. It works 12 months out of the year.
Admin
A "PHP God" is more like how the cavemen saw fire and the weather as "gods". Me no understand, must be god's work. Me listen to god.
Admin
@myself. It's obviously not supposed to show the LAST 3 month of data, but 3 month of data.
Admin
You know a varchar has to hold NULL character even if its in max length? so it has to have 5 characters varchar to hold 4 character string. alternatively he could used (fixed) char field with length of 4 but thats another story.
Admin
Actually, I think the Romans meant to have a 10 month calendar. Look at the Latin names:
September :- sept=7 October :- octo=8 November :- nova=9 December :- deca=10
The Moon just circles the Earth too many times in a year.
Admin
A SQL VARCHAR(N) has at most N characters. It is represented in the DB any way it wants, per the standard.
Your database server (or client) handles data type format for you. Then, the string gets exported to the client language as needed.
For example, PostgreSQL uses "Pascal strings" with a leading length byte for all character types internally. There's no NUL character terminator.
A C/C++ client must write the VARCHAR(N) characters to a buffer with a NUL byte. So, VARCHAR(N) means char my_str[N+1];.
Admin
Another situation where I just can't tell if I'm being trolled. I'm biting again, if you guys got me twice in the same day I'll be mighty upset.
Anyway, when you declare varchar(N) in SQL, you're setting aside space for N characters. There is an external integer that tracks how much of that space you actually use. There is NO need for a NULL terminator.
Protip: If you're storing information that will ALWAYS be a set number of characters (say, Social Security Number of 9 digits), storing in char(9) will have you 4 bytes per row compared to varchar(9).
Admin
TOWTF (The other WTF) is that Lori seems to have a problem with using php, javascript and imagemagick to generate graphs. If you want it server side and the company uses php, you use php. If you want the graph to be interactive, javascript is an option, and in order to generate the graph, imagemagick makes as much sense as HTML5.
Admin
[quote user="Rawr"]
[quote user="Rawr"] 2) Why are we storing months in a database table in the first place? Months are available in the database, and they are available for a multitude of regions and languages. [/quote] Are we reading the same WTF and the same comment? He said he would store the DATE not the month... In the WTF each month has some data associated with it. Like perhaps the number of widgets sold for that month. There is no month name involved. [/quote]
Admin
Of course, TRWTF is calling it ImageMagic instead of ImageMagick.
Admin
not a panic, a con game, did you not make $, yen, pounds, bucks, rubles(sic) rubles, pesos, etc. waiting on the next one. was tried again with 2012 but not getting enough traction, especiall with the horrible move leading the charge.
Admin
I love that you can capture picoseconds since the big bang in under 100 bits (and we got Y2K'd because we couldn't fit more than a century's worth of one-day resolution dates into 64 bits).
We could even manage keeping track of planck times since the big bang with only 200 bits.
But if we want to keep time until the heat death of the universe, we'll need more bits (but not too many - about 665 or so) to keep ticking off picoseconds as the protons slowly degenerate. Presumably the clock will stop working when entropy is maximized.
Admin
Admin
Just wondering...
Admin
[quote user="chrismcb"][quote user="Rawr"]
[quote user="Rawr"] 2) Why are we storing months in a database table in the first place? Months are available in the database, and they are available for a multitude of regions and languages. [/quote] Are we reading the same WTF and the same comment? He said he would store the DATE not the month... In the WTF each month has some data associated with it. Like perhaps the number of widgets sold for that month. There is no month name involved. [/quote] [/quote]
I think you're correct, for some reason the example in the code confused me.
Not sure how I imagined that one, but here is where I blame it on lack of caffeine, or it being a Monday... to avoid looking like the complete retard I just proved myself to be. Good catch.
Admin
BTW - fixed your quote fail, ya retard!
Admin
The government agency Miguel Orona worked for was first initial, last name. The poor guy was known (true) as morona.
Admin
Admin
Admin
[quote user="C-Octothorpe"][quote user="lesle"][quote user="QJo"][quote user="GalacticCowboy"] Then there was the place where our username used to be our first name (or diminutive) concatenated with the first letter or our surname. Yes, Chris T had an attitude problem.[/quote]
The government agency Miguel Orona worked for was first initial, last name. The poor guy was known (true) as morona.[/quote]I'd hate to have the name Maurice O'Lester...[/quote] I was at one place with the rule. Worked with an African American named Alan Ryan.
Admin
You're pretty sick if you would call that GOOD DATE MANGLING!
--Joe
Admin
Actually the old Roman calendar started in March, where the vernal equinox was. This led to "April Fools" who wanted to think that April was the second month after the change!
Admin
No, that's GOD Over Dijon. The King of Mustard.
Admin
Admin
Ah, I remember a friend from college called Ana. We had a printing system where the first page was always a cover page with your username in big letters on it. It must have been quite embarrassing for her to get the printouts. At least she had a few numbers attached to her username composed of her first name plus initial of her family name starting with "L".
Admin
If this site stopped posting stories for any chunk of code where "any reasonable test would fail" there would hardly be any stories left to read...
Admin
Seems to fit. When I was in high school, all the computers set up in classrooms, computer labs, etc all had some remote monitoring/control software on them (I forget what it was called). Anyway, the head IT guy would sometimes use it to mess with students he knew, like disabling input from the student machine and sending them messages. When he did this, he would always use the name God. So, I looked up the software he was using, downloaded a free client, and discovered that, surprise surprise, he NEVER SET A PASSWORD. So I did what any student would do: used it to control the IT guys computer and mess with his fantasy football team he had open in a browser (yep, he installed the server side on his pc for some reason). Never call yourself god, you're just making yourself a target.
Admin
Admin
You suggesting HTML5 makes no sense? Don't tell my current client, he might believe you and bang goes my contract.
Admin
I've told you before and I really don't like to find that I'm having to tell you again. My son was intellectually special, you understand, more-than-averagely deserving of extra special love and affection and care. Here you are, you nasty people, using that horrid word "retard" again. You've managed to reduce me to tears this time. Why can't you have pity on my feelings?
Admin
A friend of mine had a client called Richard Head. "Oh, just call me Dick," he said, at their first meeting.
Admin
Admin
Don't be retarded.
Admin
Admin
Now I eat humble pie.
Admin
Admin
Admin
Of course, any god would be able to forsee how long his program would last. Perhaps he knew it had a finite life.
Admin
Admin
Also, for the politically correct: I'm not lazy, I'm just energy efficient.
Admin
So fractions (with low denominator) of an hour are almost always a whole number of minutes, and fractions of a day even more so.
I'm not sure there is much need to easily find 1/8th of an hour, but I can imagine how halves, thirds, quarters -a and even eighths and ninths will allow accuracy to the second.
If we wanted simple division by all numbers 1-10 (the only one missing now is 7) we would need to go to 2520 (And which would be difficult to scale - should the factor of 7 be added to minutes or hours?). I think this current system is actually remarkably clever....
10 is handy because we have learnt to adapt it easily to allow fractions to be represented nicely, but it is not necessarily the best numbering system for all purposes.
Admin
Probably the same is true of gods.
But me, I was the Prince of Chichester. Pass the cheese dip.
Admin