php/mysql and dates

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` > $ > $...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2005
Bob
 
Posts: n/a
Default php/mysql and dates

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

Reply With Quote
  #2 (permalink)  
Old 05-16-2005
Oli Filth
 
Posts: n/a
Default Re: php/mysql and dates


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

Reply With Quote
  #3 (permalink)  
Old 05-17-2005
Bob
 
Posts: n/a
Default Re: php/mysql and dates

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

Reply With Quote
  #4 (permalink)  
Old 05-18-2005
Oli Filth
 
Posts: n/a
Default Re: php/mysql and dates

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

Reply With Quote
  #5 (permalink)  
Old 05-18-2005
Bob
 
Posts: n/a
Default Re: php/mysql and dates

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


Reply With Quote
  #6 (permalink)  
Old 05-18-2005
Oli Filth
 
Posts: n/a
Default Re: php/mysql and dates

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0