user2431709
user2431709

Reputation:

SQL Query using INTERVAL

i am using this SQL Statement in PHP:

$sql2="SELECT * from billing_pdf_archive2 where datetime = DATE(NOW() - INTERVAL 14 DAY) and sequence = '".$result["sequence"]."' ";

its working fine however it is only selecting 14 days ago exactly from the datetime field. is there any way i can make it select 14 days ago and older? so 15, 16, 17, 18 days and so on.... but never less that 14 days

Upvotes: 1

Views: 13718

Answers (1)

Kenny
Kenny

Reputation: 5410

More than 14 days ago:

$sql2="SELECT * from billing_pdf_archive2 where datetime < DATE(NOW() - INTERVAL 14 DAY) and sequence = '".$result["sequence"]."' ";

Upvotes: 1

Related Questions