I was using Microsoft's Jet database engine before. And, say, if I needed to select entries for a specific month I do this:
SELECT * FROM `table name` WHERE MONTH(`date column`)=4
But how do you do the same with SQLite?
SELECT date('now','start of month','+13 month','-1 day') as "Last Date of current month after a Year"; Here is the result. Example-6: If you want to get the last date of the current month after 4 years, the following SQL statements can be used.
First, create a new table named datetime_real . Second, insert the “current” date and time value into the datetime_real table. We used the julianday() function to convert the current date and time to the Julian Day. Third, query data from the datetime_real table.
The date() function returns the date as text in this format: YYYY-MM-DD. The time() function returns the time as text in this format: HH:MM:SS. The datetime() function returns the date and time as text in their same formats: YYYY-MM-DD HH:MM:SS.
The SQLite date() function is used to calculate the date and return it in the format 'YYYY-MM-DD'. The SQLite datetime() function is used to calculate a date/time value, and return it in the format 'YYYY-MM-DD HH:MM:SS'. The SQLite julianday() function returns the date according to julian day.
How about
SELECT * FROM table_name WHERE strftime('%m', date_column) = '04'
Date And Time Functions
SELECT * FROM `table name` WHERE strftime('%m', `date column`) = '04'
sqlite date&time functions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With