Tom
Tom

Reputation: 75

Cant sort date with Order by Clause

I am trying to use order by clause...

My code...

db.rawQuery("select * from pd_data where item_type=1 and item_date like '%" + month + "%' order by date(item_date) DESC Limit 1", null);

But this only returns one value...

My date format dd MMM yyyy.

How can i resolve this issue..?

Is it possible to sort dd MMM yyyy date format using order by clause..?

Upvotes: 0

Views: 54

Answers (2)

Sebastian
Sebastian

Reputation: 417

The One value returing is due to Limit 1 at the end of the query. Try this

db.rawQuery("select * from pd_data where item_type=1 and item_date like '%" + month + "%' order by item_date DESC ", null);

Upvotes: 1

JKL
JKL

Reputation: 1070

"This only returns one value", try to remove the Limit 1 at the end of your query. And yes it is possible to sort your date with the Order By clause.

Upvotes: 1

Related Questions