sort the dates in the bank

Asked

Viewed 444 times

0

I’m having the following problem, I can’t sort in ascending order the dates that are saved in the bank, I’m using order by no select but just sort the first two houses until I get to / causing the month to get messy, my project is android but I believe that who has knowledge with bank can help me, if anyone can thank

currently I made a table in the database just to test table schedule field date = date

with bars (05/01/2016)

I tried to register the date without the bars (05012016)

without 0 (512016)

without the 0 with the bars (5/1/2016)

and to sort select * from agenda order by data

  • Add how your table is, and how you have tried to do this query by editing the question.

  • I have already come across this problem, I think it’s sqlite problem: it treats the data type as a string or similar so you can’t sort. What I did was order in java, when I get home put the code

  • 2

    Dates shall be inserted as standard: YYYY-MM-DD or by adding HH:MM:SS if time is required. Doc

  • i used this pattern(YYYY-MM-DD ) in the bank and it worked, now I have to tidy up my android studio q is not appearing the emulator so I can test, but I believe it will be all right, thanks

1 answer

0

Victor, try to use the DESCin the ORDER BY.

Decreasing:

select * from agenda order by  data desc;

To crescent:

select * from agenda order by  data asc;
  • I only managed to fix the error when I changed the format to save the date, this is the standard that works (YYYY-MM-DD ), before it was (DD/MM/YYYY) so it only ordered the two boxes of the day

  • Vitor, which format you will use and which bank is running this query?

  • the field is as date, the problem has already been solved !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.