19

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?

2 Answers 2

51

How about

SELECT * FROM table_name WHERE strftime('%m', date_column) = '04'

Date And Time Functions

Sign up to request clarification or add additional context in comments.

6 Comments

@ahmd0 What is strftime?Can you please elaborate the query in detail
@Eshwar Chaitanya, Follow the link in the answer.
@ikegami Yeah I have gone through the link,I have understood but that's not working for me,If you find some free time,please navigate to this link,I have struck with the retrieve issue regarding date stackoverflow.com/questions/8725685/…
Can you help this is not working for me my code is below: "SELECT * FROM USER_DATA where strftime('%m', created_date) ='04'"; "created_date"->field name . In database my date format is "MM-dd-yyyy"
@Neon Warge, = '4' is quite different than = '04'
|
13
SELECT * FROM `table name` WHERE strftime('%m', `date column`) = '04'

sqlite date&time functions

1 Comment

Haha. I knew it was simple. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.