473,831 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1528

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_mod e 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_Numb er`, `work_orders`.` Date_Opened`,
`customers`.`la st_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_su b`, `part_numbers`. `description`,
`part_numbers`. `qty_in_invento ry` 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_Numb er`, `work_orders`.` Date_Opened`, `customers`.`la st_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_su b`, `part_numbers`. `description`,
`part_numbers`. `qty_in_invento ry` 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_Numb er`,

`work_orders`.` Date_Opened`,
`customers`.`la st_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_su b`, `part_numbers`. `description`,
`part_numbers`. `qty_in_invento ry` 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
1789
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 up my script for almost a week now and I still cant get it right. here is the code <?php include ("ES_includes/appconst.inc.php") ;
3
2244
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 records returned when I execute: $sql = "select * from tbl where ExpiryDate > " . date("Y-m-d"); mysql_query($sql);
20
2644
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 functions like DATE() or NOW(), I don't get a Unix value, (but rather a formatted date). So I cannot use those functions to check against my saved value.
5
3500
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, because the dates must have quotes on each side. I just don't know how make the dates right. Well I'll just show you the code and some insert statements it generates. Could anyone please help me?
2
5046
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 me how to extract all data from the start of the
6
38956
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 Unix-style timestamp and then formats it. $timestamp = "2005-04-06 15:43:34"; $time = strtotime($timestamp); print date('Y-m-d \a\t H:i', $time)."\n"; However, it seems kind of counter productive. After all, aren't people
5
3668
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 (variable dates) lie within certain ranges of times given to calcutate pricing for a hotel which has different prices depending on the season. (fixed dates). So I have this table (MYSQL) which for example says: from : to : price/night 01/01 :...
4
2423
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 I'm inserting a date using the MySQL function now(). So far so good. When I var_dump() the value from the database it says it's a string,
8
3064
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
9794
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10778
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3077
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.