Link to home
Start Free TrialLog in
Avatar of cheshirefire
cheshirefire

asked on

find results between 2 UK MySQL dates

Hi,

I hope someone can help my headache. Im trying to display all records from a MySQL database which come between 2 dates. Users can enter 2 sets of dates in a PHP form which then pieces together a 'from' date and a 'to' date in the format 30/01/2008.

Ive tried running the following code for the sql query but I either get a page of errors or nothing at all when I know there are records which match.

The date is stored as text in the format 30/01/2009 etc but still no joy.

SELECT costs.cost_invoice_date, costs.cost_job_id, costs.cost_amount_received, costs.cost_payment_method, jobs.job_description FROM costs, jobs WHERE costs.cost_job_id = $n
            AND costs.cost_amount_received != ''
            AND costs.cost_job_id = jobs.job_id
            AND costs.cost_invoice_date >= date_format('$from','dd/mm/yyyy')
            ORDER BY costs.cost_invoice_date ASC";

Can anyone help?
SELECT costs.cost_invoice_date, costs.cost_job_id, costs.cost_amount_received, costs.cost_payment_method, jobs.job_description FROM costs, jobs WHERE costs.cost_job_id = $n 
		AND costs.cost_amount_received != '' 
		AND costs.cost_job_id = jobs.job_id 
		AND costs.cost_invoice_date >= date_format('$from','dd/mm/yyyy')
		ORDER BY costs.cost_invoice_date ASC";

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial