- 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
TRWTF is the messed up formatting in this post.
Admin
The formatting is messed up
Admin
Are you sure?
Admin
It was, fixed now though.
Admin
Came here fully expecting to see a SQL query with a concatenated WHERE clause. Left disappointed.
Admin
DateTime conversionroutines in what seems to be some Delphi variant are indeed localized. It is however possible that they fixed the separators for time and date to some fixed character somewhere else in the program (which, b.t.w. is not recommended, one should use an overloaded version that supplies locale info).
Admin
In fairness, the Ctrl-C think is a WTF.
Admin
When closing terminals, my Ctrl+D's often spill over to bookmarking whatever page I'm on in Firefox.
A sudden, brutal window closing when attempting to copy some text would be really embarrassing to support as a sales rep or help desk agent. And, let me guess, right-clicking in a text box deletes the database, sends an email telling off the CEO and then formats the hard drives of everyone in the office?
Admin
Yes it is.
Admin
We, old school, developers seriously talked about hiding the mouse for our main windows developer to convince him to create keyboard shortcuts for most functions.
Good old Emacs!
Admin
Well, obviously everyone uses
Ctrl+Insert to copy Shift+Delete to cut Shift+Insert to paste
Admin
Unlike the presented source code where, traditional Pascal uses { braces } for indicating comments instead of //. It's also often possible to use the older (* two character form ) if your management has banned the use of braces, or you get paid by the amount of characters entered. In addition to comments, compiler switches and settings are also written that way, like {$X+} or ( $M 64000,0,0 *), somehow like (older versions of) Internet Explorer processes "conditional comments" in HTML. But maybe it's a problem with the syntax highlighting mechanism used in the article: it can work with C# and PHP just fine, but doesn't fully support Pascal? Hmmm...
Admin
You wouldn't happen to have a BOFH on site, would you?
Admin
Bonus points are awarded for starting a transaction which may not even be committed let alone rolled back should an exception occur.
Admin
So what would Ctrl-W in the program do? Copy the text to the clipboard?
Admin
A quick google search tells me that "German date format" simply means "YYYY-MM-DD", which is 10 characters long as required by the code. So it's assuming a fixed or default date format from that DateTimeToStr function. So this will probably work just fine, but will be flaky if the expected format can be changed for any reason. E.g. some C*O decrees that dates must now look like MM-DD-YY, in which case this code will break, since the 10-character substring will include one digit of the hour.
Admin
I first thought "at least they uses parameters for the DateTime", then I noticed they created it with string manipulation. What I usually see is all sorts of manipulation to craft a date as a string, hopefully as YYY-MM-DD, but not always.
While Remy is correct in saying a single UPDATE .. WHERE would work, if more complex logic, the developer may have wished to display the information to the user, which would also explain why "NAME", STATUS etc are included in the query.
In which case, all they would need to do is (assuming Delphi)
Note that in Pascal, the () after Date is optional - functions that have no parameters don't need to have brackets.
Even if the datetime was passed in as a parameter, there is a DateOf() function that returns the date part in all but he oldest versions of Delphi. Even back then you could simply use
Trunc(dt);
, as Delphi's TDateTime is a double-in-disguise, with the non fractional part being the number of days since 30/12/1899. The odd cut off is because Lotus 123 used it, so Excel used it, so COM uses it.... Lotus had a bug with leap years, it thought 1900 was leap.Admin
And after all that, the one thing that truly offends me in this code is the inverted capitalisation of the SQL string. It's keywords in all-caps and identifiers in lower or camel case, dammit!
Admin
Well parenthesis-star comments are much better than programming like
code code ä comment å
...or maybe in C
if (condition1 öö condition2) ä consequence(); å
The joy of ISO 646-SE2 terminals: https://www.aivosto.com/articles/charsets-7bit.html
Admin
(Explanation: on such a terminal, "}{@][|~" are replaced with national characters "åäöüÅÄÖÜ")