-1

I need a small help in mysql. Following is my table structure

enter image description here

I just wanted to know how can I get a result from 5/30/2011 to 6/30/2011 with a proper sql query. I tried with Between query but its not working.

Thanks

Mujahid

Mujahid
  • 1,227
  • 5
  • 32
  • 62

1 Answers1

0
SELECT * FROM mytable WHERE startdate > '5/30/2011' AND  startdate < '6/30/2011' 

(assuming your using date datatype for startdate)

Tom Squires
  • 8,848
  • 12
  • 46
  • 72
  • Thanks a lot. Its working though I just changed the query second data as follows: `SELECT * FROM mytable WHERE startdate >= '5/30/2011` AND enddate <= '6/30/2011'` Now its working. Thanks :) – Mujahid Aug 17 '11 at 08:38
  • Ooops got another problem, since its not a date type, I am getting some issue, is there a way to change the column type to date and convert all the current strings to date. Someone else has created this database and I'm now getting stuck on it :( – Mujahid Aug 17 '11 at 08:55
  • You will need to insert everything into a temp table then alter the original table, truncate then insert back into it. If you open a new question i will write the syntax for you. – Tom Squires Aug 17 '11 at 08:57
  • Hi Tom, I created a new one right now, can you pls answer in that one. Thanks. check the link here http://stackoverflow.com/questions/7090231/how-to-convert-a-varchar-column-type-to-date-type-without-losing-the-dates – Mujahid Aug 17 '11 at 09:02