$sql=mysql_query("SELECT PERIOD_DIFF(200404,200401) AS beda"); gregoriantojd() gampang kok... $tgl1=11; $bln1=9; $thn1=2008; $tgl2=25; $bln2=9; $thn2=2008; echo 'Selisih hari : ' . abs( gregoriantojd( $bln1, $tgl1, $thn1 ) - gregoriantojd( $bln2, $tgl2, $thn2 ) ) . ' hari'; pake fungsi absolute / abs(), supaya perhitungan selisih dibolak balik hasilnya tetep positif Untitled Document

lt;?php $tglAwal = "2008-10-20"; $tglAkhir = "2008-10-23"; mysql_connect("namahost","namauser","pass"); mysql_select_db("namadb"); $query = "SELECT datediff('$tglAkhir', '$tglAwal') as selisih"; $hasil = mysql_query($query); $data = mysql_fetch_array($hasil); echo "Selisih hari antara tanggal ".$tglAwal. " sampai tanggal ".$tglAkhir." adalah ".$data['selisih']. " hari"; ?>