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 #186251 is a reply to message #186249] Sat, 21 June 2014 21:31 Go to previous messageGo to previous message
Jrgen Exner is currently offline  Jrgen Exner
Messages: 14
Registered: March 2013
Karma:
Junior Member
On Sat, 21 Jun 2014 22:06:25 +0100, Tim Streater
<timstreater(at)greenbee(dot)net> wrote in comp.databases.mysql:
> 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.

Yes, that is a very well-known workaround commonly known as casting.

> Richard should look for something similar in
> mysql.

If he is using Julian days, then yes. Of course he could and should have
used a numerical type for this field in the first place. Then as you
discovered yourself he would not have to cast the value to a different
type.
If he is using a textual representation of a Julian calender date then
no. There he is completely on his own.
And if he had been using DATE or DATETIME then there wouldn't even be
this discussion.

jue
[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: Thu Nov 28 09:33:00 GMT 2024

Total time taken to generate the page: 0.05024 seconds