Assuming there is a timestamp column in the MySQL table that records the date and time when the news item was added, the method for choosing news from the past 6 months is:
SELECT * FROM news_table
WHERE timestamp_column >= DATE_SUB(NOW(), INTERVAL 6 MONTH);
This SQL query selects all columns (*
) from the news_table
where the value of the timestamp_column
is greater than or equal to (>=
) the current date and time minus (DATE_SUB
) 6 months (INTERVAL 6 MONTH
). The NOW()
function returns the current date and time.
Asked: 2022-07-31 11:00:00 +0000
Seen: 9 times
Last updated: Mar 23 '23