I have a table called Report Card Table. In that table there is colum called expiry date. I would like to know everybody who's card is expring in less than or equal to 90 days

SELECT *  FROM `report_card_table` WHERE expirydate>=current_date() and expiry_date<=date_add( current_date(),interval 3 month)

Instead of using comparison operator (>=) and logical operator (AND) you can use the BETWEEN operator. BETWEEN operator process the query fast as compare to comparison operator and logical operator. Use the following query to get your result.

SELECT * FROM report_card_table WHERE expirydate BETWEEN CURRENT_DATE() AND DATE_ADD(CURRENT_DATE(),INTERVAL 3 MONTH);

I want also show the already expired once.

I want also show the already expired once along with expering in 90 days.

SELECT *  FROM `report_card_table` WHERE expirydate <=  date_add( current_date(),interval 3 month)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.