Colton.Wagner Posted November 26, 2013 Share Posted November 26, 2013 Hello, I am trying to query my mysql database to return data based on a date range set. here is the code that is returning an empty set. The format is accepeted but will never return anything. Any help would be greatly appreciated. SELECT * FROM (SELECT * FROM Live_Data WHERE uid='1' 'Post_Date' >= \"2013-11-21\" AND 'Post_Date' <= \"2013-11-22\" ORDER BY id DESC) tmp ORDER BY tmp.id ASC or SELECT * FROM (SELECT * FROM Live_Data WHERE uid='$uid' 'Post_Date' BETWEEN '2013-11-21' AND '2013-11-22' ORDER BY id DESC) tmp ORDER BY tmp.id ASC Quote Link to comment https://forums.phpfreaks.com/topic/284274-handling-dates-in-mysql-between-and/ Share on other sites More sharing options...
jazzman1 Posted November 26, 2013 Share Posted November 26, 2013 Use mysql_error() or other mysql* error functions you should get a syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/284274-handling-dates-in-mysql-between-and/#findComment-1460099 Share on other sites More sharing options...
ranienter Posted November 26, 2013 Share Posted November 26, 2013 Try this: SELECT * FROM ( SELECT * FROM Live_Data WHERE uid='$uid' AND 'Post_Date' > '2013-11-21' AND 'Post_Date' <'2013-11-22' ORDER BY id DESC ) tmp ORDER BY tmp.id ASC I encourage you not to use BETWEEN. Quote Link to comment https://forums.phpfreaks.com/topic/284274-handling-dates-in-mysql-between-and/#findComment-1460190 Share on other sites More sharing options...
Barand Posted November 26, 2013 Share Posted November 26, 2013 I encourage you not to use BETWEEN. Please explain why. Quote Link to comment https://forums.phpfreaks.com/topic/284274-handling-dates-in-mysql-between-and/#findComment-1460211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.