Re: How to loop through the dates? [message #186145 is a reply to message #186134] |
Mon, 16 June 2014 16:26 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma:
|
Senior Member |
|
|
On Sun, 15 Jun 2014 19:14:22 -0400, Lew Pitcher wrote:
> On Sunday 15 June 2014 13:40, in comp.lang.php, "Denis McMahon"
> <denismfmcmahon(at)gmail(dot)com> wrote:
>
>> On Sun, 15 Jun 2014 12:11:01 -0400, richard wrote:
>>
>>> Data is ordered by date.
>>
>> See, this is where the richard database design starts to bite the richard
>> arse.
>>
>> You are storing dates as a string representation of the date, so your
>> "order by date" sql clause causes the data to be ordered according to the
>> string collation for the relevant table.
>>
>> If you want the mysql rdbms to sort the data into date sequence, then you
>> need to store the data as dates.
>
> That's good advice (the best).
>
> However, richard can get away with
> SELECT * FROM table ORDER BY STR_TO_DATE(date,date_string_format);
>
> That will convert his string dates to "real" dates for the purposes of
> ordering the resultset rows, and should come out in ascending sequence by
> calendar date.
> http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#functio n_str-to-date
>
>
>
> [snip]
What is it with you people over this damn date issue?
I am only using date in the table as a unique identifier.
I could have chosen any number of other items but this works for me quite
well.
My table cell for the unique identifier is shown as
01-01-2014 60-001
A combination of the date and songID.
When a song is played more than once on a given date, the hit counter is
increased.
|
|
|