[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

PHP Date Range Query

having an issue with this, hopefully someone can straighten me out.

SELECT * FROM notes WHERE timestamp BETWEEN ".$_REQUEST[start]." and ".$_REQUEST[end]." ORDER BY timestamp desc

timestamp records contain data as 2007-06-03 13:25:47

I'm not getting any results out of this (and I should), so any assistance would be greatly appreciated
0
mopar003
Asked:
mopar003
  • 2
1 Solution
 
mankowitzCommented:
Are you sure that your  $_REQUEST is populated? Try printing out the query before running it. Then copy/paste the query into the query browser to make sure that it should, in fact, be finding something.

The data format should be escaped with quotes.

i.e..... BETWEEN '2006-05-13 03:45:23' and '2006-05-17 01:25:23'
0
 
mankowitzCommented:
sorry, I meant that the DATE format should be enclosed with quotes.
0
 
mopar003Author Commented:
I think that was part of it, but i may have tried that as well.  At the time I was using a $_REQUEST[end] field, which may have been the actual culprit, being that end is a reserved word in PHP.  I changed it to enddate and added the quotes and allis well.  Thanks for the help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now