I have a sqlite database with a field called as fecha.
I want to get data ordered by fecha (first the newest records and at the last, the oldest ones).
My fecha field is the type text (because in sqlite there is not type date) with this format yyyy-MM-dd. Example: 2020-01-03.
I have tried this one:
SELECT * FROM table1 order by date(fecha,"yyyy-MM-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-mm-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-MM-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-mm-dd") DESC
SELECT * FROM table1 order by substr (fecha,7,2) || substr(fecha,4,2) || substr(fecha,1,2) ASC
SELECT * FROM table1 order by substr (fecha,7,2) || substr(fecha,4,2) || substr(fecha,1,2) DESC
I have written before this: DateTime.DateFormat=("yyyy-MM-dd") and DateTime.DateFormat=("yyyy-mm-dd"). I think that is not neccessary but I have tried it too.
In all of cases I get the same order in my reading.
Someone knows how can I order my records by date in sqlite?.
Thanks. I have worked in it since two days ago. Please help.
I want to get data ordered by fecha (first the newest records and at the last, the oldest ones).
My fecha field is the type text (because in sqlite there is not type date) with this format yyyy-MM-dd. Example: 2020-01-03.
I have tried this one:
SELECT * FROM table1 order by date(fecha,"yyyy-MM-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-mm-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-MM-dd") ASC
SELECT * FROM table1 order by date(fecha,"yyyy-mm-dd") DESC
SELECT * FROM table1 order by substr (fecha,7,2) || substr(fecha,4,2) || substr(fecha,1,2) ASC
SELECT * FROM table1 order by substr (fecha,7,2) || substr(fecha,4,2) || substr(fecha,1,2) DESC
I have written before this: DateTime.DateFormat=("yyyy-MM-dd") and DateTime.DateFormat=("yyyy-mm-dd"). I think that is not neccessary but I have tried it too.
In all of cases I get the same order in my reading.
Someone knows how can I order my records by date in sqlite?.
Thanks. I have worked in it since two days ago. Please help.