Difference between revisions of "SQLite - Select Date for a specific month - Extract month from a date to check that in a where clause"

(Created page with "Use strftime() - Here as an example all dates with the month July (number 7) are selected. <pre>SELECT * FROM tablename WHERE strftime('%m', date_column) = '07'</pre> More a...")
 
Line 2: Line 2:
  
 
<pre>SELECT * FROM tablename WHERE strftime('%m', date_column) = '07'</pre>
 
<pre>SELECT * FROM tablename WHERE strftime('%m', date_column) = '07'</pre>
 +
 +
<br>
 +
<br>
 +
If you want to extract the Month for the current date, then use the following SQL query:
 +
<pre>SELECT strftime('%m','now')</pre>
 +
 +
  
 
More about strftime() <br>
 
More about strftime() <br>

Revision as of 15:05, 6 October 2019

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

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



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

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


More about strftime()
https://www.w3resource.com/sqlite/sqlite-strftime.php