Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2005, 10:17 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default Select * from date1 to date2

Hi,

I can usualy test, try and correct but I haven't got a clue how to perform that query!

I have 2 date: $date1 and $date2 (y-m-d)
How do I send a query to MySQL to get all rows within those 2 dates?

Cut down of my current SQL Query:
$query = "SELECT * FROM Table_Article WHERE Article_ID LIKE '$Searchtitle'";

Which I'm assuming should look something like:
$query = "SELECT * FROM Table_Article WHERE Article_ID LIKE '$Searchtitle' FROM '$date1' to '$date2'";

but I guess its going to be harder than that.

Thanks.
 
Old March 3rd, 2005, 10:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default


SELECT * FROM Table_Article
WHERE Article_ID LIKE '$Searchtitle'
AND date_column_name BETWEEN '$date1' AND '$date2'

I'm not sure about the single quotes for a date.

 
Old March 4th, 2005, 07:35 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks - do you know if the BETWEEN is inclusive or exclusive ?
 
Old March 4th, 2005, 09:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

If it's not pulling back what you want try:

AND date_column_name >= $date1
AND date_column_name <= $date2

 
Old March 4th, 2005, 02:56 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks :)
Will check this one over the week-end :)
 
Old March 7th, 2005, 09:17 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Works great - Thank you again!
The selection is inclusive which is fine by me.
 
Old March 17th, 2005, 12:38 AM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

up stu9820






Similar Threads
Thread Thread Starter Forum Replies Last Post
Select row in GridView WITHOUT using Select button rao965 ASP.NET 2.0 Professional 1 February 15th, 2008 10:44 AM
Select from another select statement to a repeater simsen ASP.NET 2.0 Professional 0 May 2nd, 2007 04:34 PM
Fill select box and select recordset value markd Classic ASP Databases 1 February 20th, 2006 06:41 PM
get data from date1 to date2 razmar78 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 November 9th, 2004 05:47 AM
select="node1", select="node2"... Baldo XSLT 7 March 12th, 2004 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.