Page 1 of 1

Count date using Mysql

Posted: Fri Jul 01, 2005 4:43 am
by kill_bill
I got problem to view my table divided by expired date... so how to make a list of table that can divide the data by date...

for example..
1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List

I have table with date, but what kind of mysql command can divide them by expired date if so, actually i'm newbie here... perhaps i can get any solution.. thanks..

Posted: Fri Jul 01, 2005 5:05 am
by harrisonad
Do you want a single query?

Posted: Mon Jul 04, 2005 1:10 am
by kill_bill
yeah.. anything that can make me feel better.. if single way help.. it will be my pleasure if you can help me..

Re: Count date using Mysql

Posted: Mon Jul 04, 2005 1:37 am
by harrisonad
kill_bill wrote: 1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
lled Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
y_date = $data['expiry_date'];
$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
if($days_left <= 7)
$recent_list[] = $title;
elseif($days_left > 7 && $days_left <= 14)
$alert_list[] = $title;
elseif($days_left > 14)
$super_alert_list[]= $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
< 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
; 7 && $days_left <= 14)
$alert_list[] = $titl expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp; $days_left &lt;= 14)
		$alert_list&#1111;] = $title;
	elseif($days_left &amped date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_d"kill_bill"]
1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
te < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp; $days_left &lt;= 1of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp; $days_left &lt;= 14)
		$alert_list&#1111;] = $title;
	elseif($days_left &gt; 14)
		$super_alert_list&#1111;]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
"kill_bill"]
1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here
[/php:1:64; 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'tibe put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp; $days_left &lt;= 14)
		$alert_list&#1111;] = $title;
	elseif($days_left &gt; 14)
		$super_alert_list&#1111;]=  $title;
}
// now put array lists to select boxes
/te > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'exlt; 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=my"kill_bill"]
1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp; $days_left &lt;= 14)
		$alert_list&#1111;] = $title;
	elseif($days_left &gt; 14)
		$super_alert_list&#1111;]=  $titlut in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] = $title;
	elseif($days_left &gt; 7 &amp;&amp"kill_bill"]
1. list of recent file for expired date < 7 days will be put in a list called Recent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = &quote;SELECT * FROM tablename&quote;; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data&#1111;'title'];
	$expiry_date = $data&#1111;'expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left &lt;= 7)
		$recent_list&#1111;] ecent List
2. List of expired date > 7 and < 14 days will be put in a list called Alert List
3. List of expired date > 14 days will be put in a list called Super Alert List
[/quote]
I think you can accomplish this many ways. Here is an example:

Code: Select all

// prepare 3 arrays for different lists
$recent_list = $alert_list =$super_alert_list = array();
// get all items
$query = "SELECT * FROM tablename"; 
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
	$title = $data['title'];
	$expiry_date = $data['expiry_date'];
	$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
	if($days_left <= 7)
		$recent_list[] = $title;
	elseif($days_left > 7 && $days_left <= 14)
		$alert_list[] = $title;
	elseif($days_left > 14)
		$super_alert_list[]=  $title;
}
// now put array lists to select boxes
// ... i hope you know your way home from here

Posted: Mon Jul 04, 2005 4:07 am
by kill_bill

Code: Select all

$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better
Can you give me that potion please.. i'm so stuck rite now...thanks/ user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanksve me that potion please.. i'm so stuck rite now...thanksdate); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanks$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanks; // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanksff(date('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanks$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanksdate('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanksything better

Can you give me that potion please.. i'm so stuck rite now...thankspotion please.. i'm so stuck rite now...thanksr function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanks$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanksng better

Can you give me that potion please.. i'm so stuck rite now...thanks$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything better

Can you give me that potion please.. i'm so stuck rite now...thanks

Posted: Mon Jul 04, 2005 4:49 am
by harrisonad

Code: Select all

function getDateDiff($date1,$date2) {    
    $secondsdifference = $date2 - $date1;     
    $daysdifference = bcdiv($secondsdifference,86400);            
    return $daysdifference;
}
ndsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
secondsdifference,86400);
return $daysdifference;
}
[/php:1:69b94703 $secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}

function getDateDiff($date1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
econdsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
($date1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}

function getDateDiff($date1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
ate1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}
[/php:erence,86400);
return $daysdifference;
}
fference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}

function getDateDiff($date1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}