<?php

include('r_dbc.php');

$sql = "SELECT date_format(min(r.rab_date),'%d-%m-%Y') as min_rab_date, min(r.rab_date) as min_rab_date_php,
		date_format(max(r.rab_date),'%d-%m-%Y') as max_rab_date, max(r.rab_date) as max_rab_date_php
		from ccmanager r
		where r.pid = ".$pid."";
		
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
      while($row = mysqli_fetch_assoc($result)) {
		$min_rab_date 		= $row["min_rab_date"];
		$min_rab_date_php 	= $row["min_rab_date_php"];
		$max_rab_date 		= $row["max_rab_date"];		
		$max_rab_date_php	= $row["max_rab_date_php"];		
    }
} 

mysqli_close($conn);



include('r_dbc.php');

$sql = "SELECT DATEDIFF('".$max_rab_date_php."','".$min_rab_date_php."') as ccmanager_date_diff";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
      while($row = mysqli_fetch_assoc($result)) {
			$ccmanager_date_diff  = $row["ccmanager_date_diff"];
    }
} 

mysqli_close($conn);

// echo $ccmanager_date_diff;
?> 