This is a discussion on php/mysql and dates within the PHP Language forums, part of the PHP Programming Forums category; This little date formating problem is holding me up! Here is the sql query string. ..... WHERE (`work_orders`.`date_closed` > $ > $...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |