Andy Prasetya wrote:

Hello,

I'm a newbie in MySQL. I have a table that contains column 'startdate [date]' and 'enddate [date]'. Somehow, I have to execute SQL that search any entry that corresponds to the current year and current month, e.g.:

"SELECT * FROM mytable WHERE fieldx = '123' AND (startdate LIKE '2004-01-%' || enddate LIKE '2004-01-%') ORDER BY id"

This SQL works with any entry that has startdate like '2004-01-02' and enddate like '2004-01-30'.

Now, how do I modify my SQL so I can also retrieve any entry that has startdate < '2004-01-%' and enddate > '2004-01-%' ?


Just use startedate < '2004-01-01' and enddate > '2004-01-31'

That will find anything with a start date before Jan of 2004 and an end date after Jan of 2004.

Chris W


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to