...

View Full Version : Date search.



mwx6205
08-16-2012, 04:42 AM
Hi guy,

I met a problem here, I can't search for my result by insert date(format: 16-Aug-2012). I am using Microsoft Access as my database, and I am using Date/ Time data type(format: 16/8/2012 10:38:38 AM).



if (isset($_POST['date']))
{
print('<br /><center><table border="0" cellspacing="0" cellpadding="0" class="bdtxt-white"><tr class="bold"><td width="70">Service Order ID</td><td width="180">Customer Name</td><td width="90">Customer Invoice No.</td><td width="150">Date of Service Order</td><td width="100">RS Name</td><td colspan="2" width="90">Action(s)</td></tr>');
$var = $_POST['checkDate1'];

$sql4 = "SELECT so.soID, c.custName, so.dateOfServiceOrder, so.customerInvoiceNo, u.username, so.adminRemark, soFlow
FROM serviceOrder AS so, customer AS c, user AS u
WHERE so.dateOfServiceOrder = $var ";
$row = odbc_exec($conn, $sql4);

$i = 0;
while(odbc_fetch_row($row))
{
$so_id = odbc_result($row, 1);
$custName = odbc_result($row, 2);
$date_of_service_order = odbc_result($row, 3);
$cust_invoice_no = odbc_result($row, 4);
$username = odbc_result($row, 5);
$adminRemark = odbc_result($row, 6);
$soFlow = odbc_result($row, 7);

if($i%2 != 0)
{
print('<tr class="odd"><td><a href="/tabs.php?id='.$so_id.'&groupID='.$groupID.'">'.$so_id.'</a></td><td>'.$custName.'</td><td>'.$cust_invoice_no.'</td><td>'.$date_of_service_order.'</td><td>'.$username.'</td><td>');
if($soFlow == 1)
{
echo '<a href="../retailSales/editServiceOrder.php?id='.$so_id.'">Edit</a>&bull;';
}
echo'<a href="../retailSales/showServiceOrderDetails.php?id='.$so_id.'" target="_blank"><img src="/includes/image/printer.png" width="20" height="20" title="Print" alt="Print"></a></td></tr>';
$i++;

}
else
{
print('<tr class="even"><td><a href="/tabs.php?id='.$so_id.'&groupID='.$groupID.'">'.$so_id.'</a></td><td>'.$custName.'</td><td>'.$cust_invoice_no.'</td><td>'.$date_of_service_order.'</td><td>'.$username.'</td><td>');
if($soFlow == 1)
{
echo '<a href="../retailSales/editServiceOrder.php?id='.$so_id.'">Edit</a>&bull;';
}
echo'<a href="../retailSales/showServiceOrderDetails.php?id='.$so_id.'" target="_blank"><img src="/includes/image/printer.png" width="20" height="20" title="Print" alt="Print"></a></td></tr>';
$i++;
}

}
}


Any idea to overcome this problem? THANKS a lot :)

Nile
08-16-2012, 07:01 AM
Maybe the DateTime class will help.

http://www.php.net/manual/en/datetime.createfromformat.php

mwx6205
08-16-2012, 09:23 AM
Hi Nile,

What if my input is only date(16-Aug-12) ? is that possible to retrieve from db that contained with data and time(16/8/2012 10:38:38 AM)?

Best regards,
mwx6205

Nile
08-16-2012, 04:34 PM
You cannot get something from nothing. If your date is 16-Aug-12, you only have three references to match, so "10:38:38 AM" is a problem (four more variables). The DateTime will probably set these to their indexed values. I suggest using the SQL LIKE command in order to search for these types of dates.

mwx6205
08-17-2012, 04:38 AM
Ok, thank you Nile, I try to work it out see :)

mwx6205
08-17-2012, 04:44 AM
OH GOD!! I got it. Nile, thank you very much.

I am very pleased that you lend me your helping hand :)

CHEERSSS!

by the way, how can I change it to resolved status?

Nile
08-17-2012, 07:31 PM
I'm glad to help you :). To change it to resolved, go to your first post and "Edit" it (probably on the bottom righthand side). At the top you will have a select box with the option to select "resolved."

mwx6205
08-18-2012, 03:10 AM
Kind of you Nile :)

So sorry that I still can't find any resolve option there, after clicking edit, the only drop box is only for colors..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum