0

table name

receipt

id  coupondate    name      recno
1   15-04-2015     A          1
1   15-05-2015     A          1
1   15-06-2015     A          1
1   15-07-2015     A          1
1   15-08-2015     A          1
1   15-09-2015     A          1

here coupondate starts from 15-04-2015 and finished on 15-09-2015..

so i need code which display 1 to all days which comes between 15-04 and 15-09.

expected output

 15-04 16-04 17-04 18-04 19-04 20-04 21-04 22-04......like wise 15-09
   1     1     1     1     1     1     1     1                   1


SELECT RE.coupondate FROM receipt_entry RE LEFT JOIN city_master CM ON RE.city_name = CM.id WHERE CM.cityname = :cityname
                AND str_to_date(RE.coupondate,'%d-%m-%Y') BETWEEN :fromdate AND :todate ORDER BY STR_TO_DATE(RE.coupondate,'%d-%m-%Y') ASC

1 Answer 1

2

This works like a charm form me.

$date1 = new DateTime("2010-07-06");
$date2 = new DateTime("2010-07-09");
$diff = $date2->diff($date1)->format("%a");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.