473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php/mysql and dates

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
5 1503

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tiernan | last post by:
Hey everybody. I'm verrynew to PHP and MYSQL and have been working on a form that when it is submitted stores the information into a mysql database. The main problem is that i'm trying to finish...
3
by: Mark Stevens | last post by:
I am trying to do select all of the records in a table where they data has not expired. The table contains two fields Subject (varchar(100)) and ExpiryDate (Date). I am getting all of the...
20
by: Sims | last post by:
Hi, I have a field in my DB that saves the date/time as a integer. I get the time on my server using the time() function. now, moving away from php and looking at (My)SQL only. If I use...
5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
2
by: toedipper | last post by:
Hello, MYsql and PHP If I want to extract data with todays date then it's 'where blab blah = current_date()' For yesterday it's 'where blah blah = current_date()-1' But can anyone tell...
6
by: Brandon | last post by:
I'm using PHP with MySQL 4.x and was having trouble converting a datetime from MySQL into a formatted string until I ran across this solution that converts a YYYY-MM-DD HH:MM:SS string into a...
5
by: dennisfreud | last post by:
Hi, I am looking for general help here. I dont know how to start at this... maybe someone can point me in the right direction. I need to calculate how many nights of a given time frame...
4
by: Michael Sharman | last post by:
Hi guys, I'm a little confused with dates. Ok, all I want to do is store a date in MySQL as a datetime object and be able to read and format it using PHP. My datatype in MySQL is DATETIME and...
8
by: Tony B | last post by:
I have a string in a existing php script which is in the form "dd/mm/yyyy" and I need to convert it into a suitable format for mysql which is "yyyy-mm-dd" Is there a neat way of doing this in php ?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.