Question: I have table for tasks list.

I usually use linux time to set the dates but this time I tried DATE type.

how can I select all the task that their targetDate is in 2 days or less?

I know how to do it in the SQL query:

```
SELECT * FROM tasks 
WHERE `targetDate` >= CURDATE() 
  AND `targetDate`  < DATE_ADD(CURDATE(), INTERVAL 2 DAY)

```

**I would like it know how to do it in the PHP code**

```
id  int(10) 
title   varchar(250)    utf8_general_ci
text    text    utf8_general_ci
catID   tinyint(3)  
createUserID    int(4)  
createDate  date    
targetDate  date    

```

Answer: 
```
SELECT * FROM tasks WHERE targetDate BETWEEN '2015-10-13' AND '2015-10-27' 

```

OR 

```
SELECT * FROM tasks WHERE DATE_FORMAT(targetDate,'%Y-%m-%d') BETWEEN '2015-10-13' AND '2015-10-27'

```
use mysql `CURDATE()` or `INTERVAL`

```
SELECT * FROM tasks 
WHERE
targetDate BETWEEN (CURDATE() - INTERVAL 2 DAY ) and CURDATE()

```