iPixel Posted June 18, 2009 Share Posted June 18, 2009 So i need to pull data from a table and the query should go something like this. SELECT * FROM tablename WHERE Date is between 01-JUN-09 to 18-Jun-09 How do i write the bold part... im not sure how the range thing works. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/ Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 So i need to pull data from a table and the query should go something like this. SELECT * FROM tablename WHERE Date is between 01-JUN-09 to 18-Jun-09 How do i write the bold part... im not sure how the range thing works. Thanks. Your date field has to be either type 'date' or 'timestamp'. It can't be a varchar. Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/#findComment-859163 Share on other sites More sharing options...
iPixel Posted June 18, 2009 Author Share Posted June 18, 2009 The field is DATE type, and it contains info in this format DD-MON-YY. Bah im an idiot, i posted this on MySQL when it's an Oracle database LOLz. But i guess there might be enough similarities for me to figure out once i know the MySQL query. Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/#findComment-859169 Share on other sites More sharing options...
PFMaBiSmAd Posted June 18, 2009 Share Posted June 18, 2009 And the BETWEEN ... AND ... syntax http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between does not use the words "is" and "to" (I know you were asking in pseudo code, but the documentation exists for a reason - so that you can research the basics yourself.) Edit: mysql forum questions get mysql answers. Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/#findComment-859171 Share on other sites More sharing options...
Maq Posted June 18, 2009 Share Posted June 18, 2009 It's basically the same syntax, simple Google search could have solved this. between Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/#findComment-859172 Share on other sites More sharing options...
iPixel Posted June 18, 2009 Author Share Posted June 18, 2009 I suck at knowing what phrase to use in order to get my results haha. Thanks Guys! I'll check out the link. Quote Link to comment https://forums.phpfreaks.com/topic/162815-probably-a-noob-query-question-chosing-date-range/#findComment-859176 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.