Roger
Roger

Reputation: 4259

Problems selecting date

Here are some queries I'm making and the results I'm receiving. What I'm trying to end up with is a list of months and years. So I want to see a result of 02-2011, 03-2011, 04-2011. But I can't seem to get it... what should I do?

select date from record;
04-13-2011
04-14-2011
03-14-2011
02-14-2011
sqlite>

select strftime('%m-%Y') from record;
04-2011
04-2011
04-2011
04-2011
sqlite>

select date from record group by date('%m-%Y');
02-14-2011
sqlite>

select strftime('%m-%Y', date) from record group by date('%m-%Y');
note: blank row
sqlite>

Upvotes: 0

Views: 151

Answers (1)

Michael Krelin - hacker
Michael Krelin - hacker

Reputation: 143071

Maybe

select substr(date,0,5) from record;

Your date seems to be a string column. Anyway, in the second query you select current month and year for each row, the same goes for GROUP BY clause of subsequent queries.

Upvotes: 1

Related Questions