Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Date search.

  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Date search.

    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).

    Code:
    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

  • #2
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts
    Maybe the DateTime class will help.

    http://www.php.net/manual/en/datetim...fromformat.php

  • #3
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts
    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.

  • Users who have thanked Nile for this post:

    mwx6205 (08-17-2012)

  • #5
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Ok, thank you Nile, I try to work it out see

  • #6
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    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?
    Last edited by mwx6205; 08-17-2012 at 04:23 AM.

  • #7
    Regular Coder Nile's Avatar
    Join Date
    Jun 2008
    Posts
    280
    Thanks
    2
    Thanked 46 Times in 46 Posts
    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."

  • Users who have thanked Nile for this post:

    mwx6205 (08-18-2012)

  • #8
    New Coder
    Join Date
    Jun 2012
    Posts
    44
    Thanks
    17
    Thanked 0 Times in 0 Posts
    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..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •