SQLite - Select Date for a specific month - Extract month from a date to check that in a where clause

Revision as of 15:16, 6 October 2019 by Ardaut (talk | changes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Use strftime() - Here as an example all dates with the month July (number 7) are selected.

SELECT * FROM tablename WHERE strftime('%m', datecolumn) = '07'

tablename is your table name and datecolumn is your column where your date is saved.

If you want to extract the Month for the current date, then use the following SQL query:

SELECT strftime('%m','now')

More about strftime()