Makky
Makky

Reputation: 17471

SQLite Group by Month

I am using SQLite Database and in one my table has field purchased_date (TEXT ,since DATE is not in SQLLite)

Now I want to run query that return me all the results where user purchased in Month of February 2012

I am storing Dates in following format

Tue Mar 27 09:38:31 BST 2012

Is it possible to run query for above date format or do I need to put in different format ?

Upvotes: 2

Views: 4054

Answers (1)

Rajeev Shenoy
Rajeev Shenoy

Reputation: 932

You can use the strftime built-in function to extract the month from the stored text value and group by this.

A full list of the datetime functions can be found here http://sqlite.org/lang_datefunc.html

Upvotes: 1

Related Questions