|
![](/images/resource/spacer.gif) |
|
ขอทราบวิธีการ นับจำนวนวันที่ ที่ส่งสินค้าก่อนกำหนด และส่งช้าตามกำหนด ครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (PHP)
#หาระยะห่างของวัน
function DateDiff($date_in,$date_out){
return (strtotime($date_out) - strtotime($date_in))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24
}
#การใช้งาน
$want_date = '2015-07-20';
$transport_date = '2015-07-20'
$countDate = DateDiff($want_date, $transport_date);
if( $countDate>0){
echo 'ส่งก่อนกำหนด';
} else if($countDate<0){
echo 'ส่งช้ากว่ากำหนด';
} else {
echo 'ส่งตรงกำหนด';
}
เอาไปประยุกต์เอานะครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-29 11:52:47 |
By :
arm8957 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ถ้าใช้ SQL
Code (SQL)
select
count(*) all_transport,
sum(want_date<transport_date) after_due,
sum(want_date>transport_date) before_due,
sum(want_date=transport_date) equal_due
from table
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-07-29 12:29:52 |
By :
NewbiePHP |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 01
|