php - Need all MySQL rows with dates in the next 7 days, but the date column is not formatted normally -


itemprop = "text">

I have a column in my database that is 'ScheduledDate', that I need an ScheduledDate within 7 days from all the rows in the database today.

I can use a question like this:

  SELECT * FROM tblName WHERE 'fixed date' & gt; MM: DATE_ADD (now () (), interval 7 days  

Only one problem, the 'scheduledDate' column is not formatted as MySQL timestamp (YYYY-MM-YYY HH ), But formatted as a standard American date (07/09/2014). Is there a way to capture all the rows in my query in the next 7 days? I was thinking that it may be possible that DATE_FORMAT But I'm unable to find it.

You can convert a date to a string using str_to_date () :

  where str_to_date (`scheduledDate`, '% M /% d / % Y ') between now () and DATE_ADD (now (), interval 7 days)  

The argument also needs to be changed. The use of between the above But it may be that your code no longer needs an external time component on . Maybe it is close:

  where str_to_date (`scheduledDate`) , '% M /% d /% Y') CURRENT_DATE () and DATE_ADD (between CURRENT_DATE, interval 7 days)   

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -