![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| looking to retrieve data from a database with a query like this :- $Query = "SELECT * FROM database WHERE created >= '$from' AND created <= '$to'"; they are dates but not stored in the database as such - they are stored as text eg 01/08/2003 the query works fine if i just $Query = "SELECT * FROM database WHERE created = '$from' "; it pulls all the data with the $from variable any ideas why it wouldnt work ? | |||
|
| Advertisements |
| | #2 | ||
| Storing dates, numbers and such as text, varchar, or similar string/alphanumeric datatypes, will cause MySQL to sort them by their alphanumeric value, and not their number value. My suggestion: Convert the dates to timestamp values, and store them as int, double, or something of the similar. "luna" <luna@moonbase.com> wrote in message news:bi4nqg$6a7$1@newsg2.svr.pol.co.uk... > looking to retrieve data from a database with a query like this :- > > $Query = "SELECT * FROM database WHERE created >= '$from' AND created <= > '$to'"; > > they are dates but not stored in the database as such - they are stored as > text > eg 01/08/2003 > > the query works fine if i just > $Query = "SELECT * FROM database WHERE created = '$from' "; > it pulls all the data with the $from variable > > any ideas why it wouldnt work ? > > > > | |||
|
| | #3 | ||
| "luna" <luna@moonbase.com> wrote in message news:<bi4nqg$6a7$1@newsg2.svr.pol.co.uk>... > > looking to retrieve data from a database with a query like this :- > > $Query = "SELECT * FROM database WHERE created >= '$from' > AND created <= '$to'"; > > they are dates but not stored in the database as such - they > are stored as text eg 01/08/2003 Unfortunately, this is not the way it works with computers. Computers are dumb and take everything you tell them at face value. So if something is not declared as a date, then you shouldn't expect a computer to handle it as a date. > the query works fine if i just > $Query = "SELECT * FROM database WHERE created = '$from' "; > it pulls all the data with the $from variable > > any ideas why it wouldnt work ? It doesn't work because `created` is not a DATE field. Cheers, NC | |||
|
| | #4 | ||
| Junior Member | burwood nursing college nursing continuing education nursing school accelerated nursing degree graduate nursing course nursing career education classesusa com legal nurse training programs take nurse classes or division 1 nursing courses nursing colleges nursing education issues city college of san francisco nursing nursing programs neonatal nursing courses nursing program college nursing degree nursing programs in pa nursing education classes nurse class nursing courses 2008 nursing certification class practical nursing course first nursing class international nursing courses
__________________ diploma nursing program | ||
| | |
| Featured Websites | ||||
|
![]() |
| Tags: problem, query, select, stuff |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "select" query dies, not sure why | Phil Powell | PHP | 3 | 07-01-2007 5:24 PM |
| SQL SELECT Query Prob | luna | PHP | 2 | 07-01-2007 5:06 PM |
| Help with a select query | Beetlegeuse | Database | 0 | 06-10-2007 12:19 AM |
| problem with select count(*) | Ben | Database | 2 | 05-31-2007 8:49 PM |
| SELECT COUNT(*) problem | JB | Database | 3 | 05-31-2007 8:42 PM |
| Featured Websites | ||||
|