SQLite & Dates

You must Login before you can answer or comment on any questions.

I'm trying to select data from an SQLite database where all of the content was published on one date regardless of the year it was published in. For example: every July 15th listed in the database.

This is my code so far.

SELECT Date, Content FROM MYDATABASE WHERE Date = date('now')

How can I make it so that all previous entries on the current date are also included.

Thanks, Max.

2 Answers

Well 'now' gives you the current Date. What you need is a specific Date. I would try something like this

var currentDay = getCurrentDay(); // e.g. 10
..
SELECT ... Where substring(Date, 8, length(Date)) = currentDay
Somthing like that

The following code works in SQLite Manager but for some reason it does not work in titanium.

SELECT Date, Content FROM MYDATABASE WHERE strftime('%m%d', Date) = strftime('%m%d', date('now'))
I'm not sure why it is causing the following error: "Uncaught SyntaxError: Unexpected String."

Your Answer

Think you can help? Login to answer this question!