473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Get Products with expiry days within 90 days

I need to get list of products that has expiry days withen 90 days from current date.
I have written the below coded but it is displaying nothing even when i have some withen 5 days.

Expand|Select|Wrap|Line Numbers
  1.      <?php    
  2.                             include "Connections/conn.php";
  3.  
  4.  
  5.  
  6.  
  7.  
  8. //PHP Example code to add one moth to a date
  9.  
  10. $todayDate = date("m/d/Y");// current date
  11. //echo "Today: ".$todayDate."<br>";
  12.  
  13. //Subtract 90 day to today
  14. $dateOne = strtotime(date("m/d/Y", strtotime($todayDate)) . "-3 month");
  15.  
  16.  
  17.      $expirydate = mysql_query("select * from app where license_expiry <= '$dateOne'");
  18.     //  $query = mysql_query("SELECT * from tinvest where account = '$account' ORDER BY `date` DESC");
  19.  
  20.           $r_id = array();
  21.           $amt  = array();
  22.           $yr = array();
  23.           $pdate = array();
  24.            $ref_i= array();
  25.  
  26.  
  27.     while ($row = mysql_fetch_array($expirydate)){    
  28.          array_push($r_id, $row['app_name']);
  29.          array_push($amt, $row['app_version']);
  30.          array_push($yr, $row['entity']);
  31.          array_push($pdate, $row['license_expiry']);    
  32.          array_push($ref_i, $row['id']);    
  33.  
  34.         }    
  35.  
  36.         for($i=0; $i<sizeof($ref_i); $i++) {
  37.  
  38.  
  39.     ?>
  40.                             <tr>
  41.                               <td height="21" align="center" valign="top" > <span class="style2"><?php echo $ref_i[$i]; ?></span></td>
  42.                               <td align="left" valign="top"><span class="style10"><?php echo $r_id[$i]; ?></span></td>
  43.                               <td align="left" valign="top"><span class="style10"><?php echo $yr[$i]; ?></span></td>
  44.                               <td align="left" valign="top" class="style12"><?php echo $pdate[$i]; ?></td>
  45.                             </tr>
  46.                             <?php 
  47.         }
  48.                   ?>
  49.  
Please help
May 20 '13 #1

✓ answered by neo008

Hi tutu saint,

First of all you shouldn't subtract 90 days rather add three month to the today date.

If your $oneDate will be having the date of +90 days from the todayDate then if you find all products which are about to expire within 90 days simply fire a sql query like -

"select ID, EXPIRY_DATE from tblProducts where EXIRY_DATE between $todayDate and $oneDate order by EXPIRY_DATE ASC";

Remember this result will not show the expired products, means products which have their expiry date less than today date. If you want to include expired products then

"select ID, EXPIRY_DATE from tblProducts where ((EXIRY_DATE between $todayDate and $oneDate) OR (EXPIRY_DATE < $todayDate)) order by EXPIRY_DATE ASC";

hope this might help.


ne☼

1 2282
neo008
85
Hi tutu saint,

First of all you shouldn't subtract 90 days rather add three month to the today date.

If your $oneDate will be having the date of +90 days from the todayDate then if you find all products which are about to expire within 90 days simply fire a sql query like -

"select ID, EXPIRY_DATE from tblProducts where EXIRY_DATE between $todayDate and $oneDate order by EXPIRY_DATE ASC";

Remember this result will not show the expired products, means products which have their expiry date less than today date. If you want to include expired products then

"select ID, EXPIRY_DATE from tblProducts where ((EXIRY_DATE between $todayDate and $oneDate) OR (EXPIRY_DATE < $todayDate)) order by EXPIRY_DATE ASC";

hope this might help.


ne☼
May 25 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Vince C. | last post by:
Hi all. I'm trying to set a cookie expiry date but my script is JS (JavaScript). I've tried Response.Cookies("Test").Expires = Date(); Response.Cookies("Test").Expires =...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
7
by: Stu | last post by:
Is there a simple function call within "C" that I can use to convert number of seconds (keep in mind this may be a type longlong and has to work on UNIX and NT) into Days, months, Hours, Minutes...
10
by: Scott Kilbourn | last post by:
Hi, Does anyone know how to accurately calculate the number of days that have elapsed since 01/01/0000? I'd appreciate any help anyone could give me. Thanks
19
by: Ricardo Perez Lopez | last post by:
Hello everyone: I'm a PostgreSQL newbie, working now with dates, times, timestamps and intervals. I have three questions about the above: FIRST: --------
1
by: cknkomo | last post by:
Hie I am learning VB and I have a table with the following fields: - EmployeeNo - Date of Engagement - From Date - End Date - Days Acrued - Days taken
3
by: hharry | last post by:
Hello All, I'm writing an app to track file transfer activity. I have this enum to represent days of the week: Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4
4
realin
by: realin | last post by:
hi guys.. I have made a function which counts the numbers of days or hours or minutes from the current datetime to the give datetime.. but i am confused while displaying number of days along with...
4
by: moyoal | last post by:
Dears, Help me how to create a ageing report for 30 days,60 days and 90 days, anyone can help me to have standard select query. Opening Balance 30 days 60 days 90 days thanks in advance,
8
by: wild wolf | last post by:
#include <iostream> int main() { int year,month,date,days,feb; cout<<"please input a date(eg. 2010 8 10)"; cin>>year>>month>>date; if((year%4==0&&year%100!=0)||year%400==0) feb=29; ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.