Count date using Mysql
Moderator: General Moderators
Count date using Mysql
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..
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..
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
Re: Count date using Mysql
I think you can accomplish this many ways. Here is an example: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
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 here3. 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$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$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 = "e;SELECT * FROM tablename"e;;
$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 &ed 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 = "e;SELECT * FROM tablename"e;;
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
$title = $dataї'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 here2. 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 = "e;SELECT * FROM tablename"e;;
$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 <= 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 = "e;SELECT * FROM tablename"e;;
$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 here1. 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 = "e;SELECT * FROM tablename"e;;
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
$title = $dataї'title'];
$expiry_date = $dataї'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ї'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 = "e;SELECT * FROM tablename"e;;
$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
/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"e;;
$result = mysql_query($query);
while($data=mysql_fetch_array($result)){
$title = $dataї'title'];
$expiry_date = $dataї'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"e;;
$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 = "e;SELECT * FROM tablename"e;;
$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ї]= $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 = "e;SELECT * FROM tablename"e;;
$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 &&"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 = "e;SELECT * FROM tablename"e;;
$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ї] 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 hereCode: Select all
$days_left = getDateDiff(date('Y-m-d',$expiry_date); // user function or anything betterCan 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
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
Code: Select all
function getDateDiff($date1,$date2) {
$secondsdifference = $date2 - $date1;
$daysdifference = bcdiv($secondsdifference,86400);
return $daysdifference;
}$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;
}