By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,771 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,771 IT Pros & Developers. It's quick & easy.

php/mysql and dates

P: n/a
Bob
This little date formating problem is holding me up!

Here is the sql query string.

.....

WHERE
(`work_orders`.`date_closed` > $ > $start_date)
AND (`work_orders`.`date_closed` < $end_date)
ORDER BY
(`work_orders`.`date_closed`)";

The dates are in the 2005-05-16 format already.
A typical start_date might be: 2005-05-11 with end_date of 2005-05-16

I get no results returned even though there are records that meet that
criteria.

help please.

bob

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Bob wrote:
This little date formating problem is holding me up!

Here is the sql query string.

....

WHERE
(`work_orders`.`date_closed` > $ > $start_date) ^
^
Are you sure you meant this dollar sign to be here?
AND (`work_orders`.`date_closed` < $end_date)
ORDER BY
(`work_orders`.`date_closed`)";

The dates are in the 2005-05-16 format already.
A typical start_date might be: 2005-05-11 with end_date of 2005-05-16


Dates and times need to be delimited with single quotes in SQL queries.

If a MySQL call doesn't work, either turn on mysql.trace_mode the
directive, or echo a mysql_error() call to find out what the problem
is!!

--
Oli

Jul 17 '05 #2

P: n/a
Bob
I don't know how that $ got in there, it's not in the code. And it
doesn't work with out the $ either. The sql string is as follows:
SELECT `work_orders`.`Work_Order_Number`, `work_orders`.`Date_Opened`,
`customers`.`last_name`, `work_orders`.`Due_date`,
`work_orders`.`priority`, `work_orders`.`Part_Number`,
`work_orders`.`Qty`, `work_orders`.`Qty_Shipped`,
`work_orders`.`Value`, `part_numbers`.`part_number`,
`part_numbers`.`part_number_sub`, `part_numbers`.`description`,
`part_numbers`.`qty_in_inventory` FROM `customers`, `work_orders`,
`part_numbers` WHERE (`work_orders`.`date_closed` > 2005-05-01) AND
(`work_orders`.`date_closed` < 2005-05-17)
which returns:

Number of work orders in database= 0

Jul 17 '05 #3

P: n/a
Bob wrote:
I don't know how that $ got in there, it's not in the code. And it
doesn't work with out the $ either. The sql string is as follows:
SELECT `work_orders`.`Work_Order_Number`, `work_orders`.`Date_Opened`, `customers`.`last_name`, `work_orders`.`Due_date`,
`work_orders`.`priority`, `work_orders`.`Part_Number`,
`work_orders`.`Qty`, `work_orders`.`Qty_Shipped`,
`work_orders`.`Value`, `part_numbers`.`part_number`,
`part_numbers`.`part_number_sub`, `part_numbers`.`description`,
`part_numbers`.`qty_in_inventory` FROM `customers`, `work_orders`,
`part_numbers` WHERE (`work_orders`.`date_closed` > 2005-05-01) AND
(`work_orders`.`date_closed` < 2005-05-17)


Did you read the second half of my previous comment??

--
Oli

Jul 17 '05 #4

P: n/a
Bob
Yes, I did. But I'll have to read up on those mysql commands.
I am not familiar with them.
I was assuming the sql query was working, but that I was not
structuring the query the correctly.

Oli Filth wrote:
Bob wrote:
I don't know how that $ got in there, it's not in the code. And it
doesn't work with out the $ either. The sql string is as follows:
SELECT `work_orders`.`Work_Order_Number`,

`work_orders`.`Date_Opened`,
`customers`.`last_name`, `work_orders`.`Due_date`,
`work_orders`.`priority`, `work_orders`.`Part_Number`,
`work_orders`.`Qty`, `work_orders`.`Qty_Shipped`,
`work_orders`.`Value`, `part_numbers`.`part_number`,
`part_numbers`.`part_number_sub`, `part_numbers`.`description`,
`part_numbers`.`qty_in_inventory` FROM `customers`, `work_orders`,
`part_numbers` WHERE (`work_orders`.`date_closed` > 2005-05-01) AND
(`work_orders`.`date_closed` < 2005-05-17)


Did you read the second half of my previous comment??

--
Oli


Jul 17 '05 #5

P: n/a
Bob wrote:
Oli Filth wrote:
Did you read the second half of my previous comment??
Yes, I did. But I'll have to read up on those mysql commands.
I am not familiar with them.


More relevant than that, the bit about having to delimit date strings
in MySQL with single quotes.
I was assuming the sql query was working, but that I was not
structuring the query the correctly.


I can tell you right now, it wasn't correct, because of the date thing.

--
Oli

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.