Hello, I've got a little problem with a select statement using Mysql.
I have a table named tblNews where I have a field named newsDate which stores the date the news article was created. I've used the following sql select statement to get all records where the month is the same as the current month.
SELECT * from tblNEWS WHERE extract(MONTH from newsDate) = extract(MONTH from current_date) Order By newsDate DESC
Works fine, returns all rows where the current_month is = to the month in newsDate. However, I don't want it to return all rows for that month in previous years, only for the current year.
I tried the following select statement to achieve this:
SELECT * from tblNEWS WHERE extract(MONTH from newsDate) = extract(MONTH from current_date) AND extract(YEAR from newsDate) = extract(YEAR from current_date) Order By newsDate DESC
That select statement returns no rows at all. Am I missing something here?
I have a table named tblNews where I have a field named newsDate which stores the date the news article was created. I've used the following sql select statement to get all records where the month is the same as the current month.
SELECT * from tblNEWS WHERE extract(MONTH from newsDate) = extract(MONTH from current_date) Order By newsDate DESC
Works fine, returns all rows where the current_month is = to the month in newsDate. However, I don't want it to return all rows for that month in previous years, only for the current year.
I tried the following select statement to achieve this:
SELECT * from tblNEWS WHERE extract(MONTH from newsDate) = extract(MONTH from current_date) AND extract(YEAR from newsDate) = extract(YEAR from current_date) Order By newsDate DESC
That select statement returns no rows at all. Am I missing something here?