Nathan Sri
Nathan Sri

Reputation: 103

mysql select 3days records from today

SELECT * FROM `user` 
WHERE name !='' AND `date_created` BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 3 Day ) 
AND DATE_SUB( CURDATE( ) ,INTERVAL 0 Day ) 
ORDER BY `date` ASC

The above query brings record 3day before from todays date.

but i need 3day records from today,which means tomorrow , day after tomorrow etc.

date_created is mysql date format.

Upvotes: 0

Views: 6675

Answers (2)

Hiren Kubavat
Hiren Kubavat

Reputation: 109

I have created this will return previous 3 days record

select * from events where DATEOFEVENT IN (select date(curdate()-3 ))

Upvotes: 0

Nicola Cossu
Nicola Cossu

Reputation: 56357

SELECT * FROM `user` 
WHERE name !='' 
AND `date_created` BETWEEN curdate() and curdate() + interval 3 day
ORDER BY `date`

Upvotes: 6

Related Questions