I have a DB where I store records with a TEXT field that contain a date, in the format Year-month-day Hours:minutes:seconds.
For example now would be 2016-10-25 12:56:00
For some reasons (still have to discover where is the bug) sometimes the record is stored with a missing zero.
For example 2016-06-17 05:50:43 is stored as 2016-6-17 05:50:43
When it happens, I have troubles in sorting the records by date with the query:
SELECT * FROM records ORDER BY StoreDate DESC
The resul is like this (first field is the primary key):
12530,2016-6-17 05:50:43
29663,2016-07-23 17:02:13
29662,2016-07-23 17:01:59
29661,2016-07-23 17:01:27
29660,2016-07-23 17:00:57
The first record of the result is of june 17th (should be 2016-06-17) but always appear as the most recent in the list
Anybody is able to explain this ?
For example now would be 2016-10-25 12:56:00
For some reasons (still have to discover where is the bug) sometimes the record is stored with a missing zero.
For example 2016-06-17 05:50:43 is stored as 2016-6-17 05:50:43
When it happens, I have troubles in sorting the records by date with the query:
SELECT * FROM records ORDER BY StoreDate DESC
The resul is like this (first field is the primary key):
12530,2016-6-17 05:50:43
29663,2016-07-23 17:02:13
29662,2016-07-23 17:01:59
29661,2016-07-23 17:01:27
29660,2016-07-23 17:00:57
The first record of the result is of june 17th (should be 2016-06-17) but always appear as the most recent in the list
Anybody is able to explain this ?