FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Putting it all together
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Storing dates [message #186252 is a reply to message #186250] Sat, 21 June 2014 21:33 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <lo4sa4$h1p$1(at)dont-email(dot)me>, Jerry Stuckle
<jstucklex(at)attglobal(dot)net> wrote:

> On 6/21/2014 5:06 PM, Tim Streater wrote:
>> In article <XnsA353998B95688dougmilmaccom(at)78(dot)46(dot)70(dot)116>, Doug Miller
>> <doug_at_milmac_dot_com(at)example(dot)com> wrote:
>>
>>> richard <noreply(at)example(dot)com> wrote in
>>> news:hzk4wa449wa$(dot)3xtj0jkxz78o$(dot)dlg(at)40tude(dot)net:
>>>> On Sat, 21 Jun 2014 17:42:29 +0000 (UTC), Doug Miller wrote:
>>>> >> richard <noreply(at)example(dot)com> wrote in
>>>> > news:1mddkhwt2mr0v$.1m6eithcu7iod.dlg@ 40tude.net:
>>>> > >>> As for the date usage on MY database tables, I am only using a
>>>> >> date as a reference.
>>>> > >> Patently false, as you have posted questions here asking for
>>>> > help resolving your problems in sorting by the date.
>>>> > >>> I really don't give a damn what your philosophy or ideals are
>>>> >> behind the so called "proper ways" of obtaining a date.
>>>> > >> Which is exactly *why* you have problems sorting by the date.
>>>> > The problem with sorting is, it treats any value given as a
>>>> string, then determines which has the lowest value in total.
>>>
>>> Yes, I understand that. That results directly from storing dates as
>>> strings,
>>> and is exactly the reason that everyone here has been telling you to
>>> store your dates in a
>>> column that has
>>> the DATE datatype, not CHAR.
>>> Your refusal to follow that advice -- apparently stemming from your
>>> inability
>>> to understand that there even *are* datatypes other than NUMERIC and
>>> CHAR -- is the entire reason you are having this sorting problem.
>>
>> I have a field which contains values like 3.7, 4.2, etc. But when I
>> defined the field (in SQLite) I made it a TEXT field, forgetting that I
>> would need to be able to sort on that field.
>>
>> My workaround is to convert the string to floating at the time of the
>> sort. In SQLite I do:
>>
>> ... ORDER BY ROUND(myfield,1);
>>
>> which works just fine. Richard should look for something similar in
>> mysql.
>
> Why don't you fix your database?
>
> The way you're doing it cannot use an index and will call round() for
> EVERY row in the sort.

I'd have to ask a number of users to convert their data when they next
upgrade the software. Trouble is in SQLite you can't just redefine a
table column to be a different type; ALTER TABLE is somewhat limited.
I'd have to copy the whole table to another, DROP the first one, RENAME
the new one, VACUUM the database to get its size down. OK, it's doable,
but I'm replying on less-than-technically-savvy users to run a Terminal
script on their own machine to effect this change.

In my own use of the app, I've got 65 databases that an update script
would have to find, recursively in an arbitrary folder structure. One
user has 1000. The recursion part is actually easy, that app already
does that at startup to verify that the user hasn't moved some
databases around by hand while the app wasn't running. I just feel a
shade nervous about distant people (i.e., not me) running a one-off
script.

In richard's case, it didn't sound like he has a huge number of rows,
so it struck me that a workaround wouldn't have much of a performance
impact. In mine, the column in question is unlikely to be a popular one
for sorting.

--
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: str_replace does not like empty quotes
Next Topic: SplFileObject always returns an extra "last" line -- why?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 00:11:44 GMT 2024

Total time taken to generate the page: 0.04162 seconds