Hi this is my table structure.
I need one result from this.
There is a field named LAPeriodStart in this table.
If LAPeriodStart date is 2009-01-05
Site Id is 4067
Today Date is 2009-12-07
1. Now I need to calculate LAPeriodStart Month from the date(2009-01-05) How its Possiblle?
2. If month of current date is one less then the month of LAPeriodStart then I need to show Current Status Due(means payment is due in next month as software processed all payments one month advance)

`lease_center` (
  `SiteId` varchar(11) NOT NULL,
  `Code` varchar(6) NOT NULL,
  `OwnerName` varchar(100) NOT NULL,
  `Mobile` varchar(100) NOT NULL,
  `Landline` varchar(50) NOT NULL,
  `LAD` varchar(3) NOT NULL,
  `POD` varchar(3) NOT NULL,
  `LA` varchar(40) NOT NULL,
  `LAPeriodStart` date NOT NULL,
  `LAPeriodEnd` date NOT NULL,
  `PO` varchar(40) NOT NULL,
  `POStartDate` date NOT NULL,
  `POEndDate` date NOT NULL,
  `BankACNo` varchar(100) NOT NULL,
  `SPA` varchar(40) NOT NULL,
  `SPAD` varchar(40) NOT NULL,
  `ch` varchar(25) NOT NULL DEFAULT 'Click here to view',
  `User` varchar(50) NOT NULL,
  `time` time NOT NULL,
  `Date` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Recommended Answers

All 5 Replies

if LAPeriodStart 2009-01-05 means Payment Month = 01(January)
Processed Month = 12(December) Always 1 month Before.
current month = 12 (Decemeber)

Now I need to show Payment Due Status
If ( currnet month = Processed month )
then Result should be Payment Due NOW
else
Pament Not Due .

SELECT month( `LAPeriodStart` - INTERVAL 1
MONTH )
FROM lease_center
WHERE `SiteId` = 'C-LHR-4067'

this is a query which I used to get process month as its one month in advance.

Now I need to compare the result with current month.
If current month = result of above query
then payment is due.
Please suggest me ...

SELECT month( `LAPeriodStart` - INTERVAL 1
MONTH )
FROM lease_center
WHERE `SiteId` = 'C-LHR-4067'

this is a query which I used to get process month as its one month in advance.

Now I need to compare the result with current month.
If current month = result of above query
then payment is due.
Please suggest me ...

see it once.link .i hopes it will help

I have got the solution.
tell me is it right way to do it?

I have done with this ....
thanks for everyone.

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }


mysql_select_db("onm", $con);



$result = mysql_query("SELECT month( `LAPeriodStart` - INTERVAL 1
MONTH )
FROM lease_north
WHERE `SiteId` = 'N-AJK-9121' ");


while($row = mysql_fetch_array($result))
  {
  echo "<table cellpadding=2 cellspacing=2 width=100%>
<tr>


</tr>";

  echo "<tr>";
		$today = date('n');
				

	if ( $today == $row[0] )
	{  echo "<tr>";
  echo "<th bgcolor=#FFCC00  width=250px>Current Status</th>";
  echo "<td bgcolor=#FEE9A9>" ."Payment Due". "</td>";
    echo "</tr>";

	}
	else 
	{
 echo "<tr>";
  echo "<th bgcolor=#FFCC00  width=250px>Current Status</th>";
  echo "<td bgcolor=#FEE9A9>" ."Not Due". "</td>";
    echo "</tr>";
}
	
	

	
	
  }
echo "</table>";


mysql_close($con);



?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.