dannybrazil Posted January 31, 2010 Share Posted January 31, 2010 Hello I have a simple problem tat I have not enough knowledge with sql to solve. I have this : $q=mysql_query("SELECT * FROM pairs WHERE pair='$pair' AND text_comment!='' AND graph_date = cast(now() as date) ORDER BY id DESC"); As you can see now it will show only where : graph_date = cast(now() as date) Now , what I basically want is to create an if() else command that will divide it into 3 main categories 1. Show only the graph_date from today + 7 days (a week) from now 2. Show only the graph_date from today + 30 days (a month) from now I thought that I just need to add the +30 but Im not sure...lets say if today is 25th and I need it to show for a week from now its already NEXT month around the 2nd Any help ? Link to comment https://forums.phpfreaks.com/topic/190464-date-sql-question/ Share on other sites More sharing options...
dannybrazil Posted January 31, 2010 Author Share Posted January 31, 2010 I think I wrote something wrong I need it to show and add with a static date for 7 or 30 days Example: I have an entry with the date of 25th of jan' (In the table it has a field names 'week') and I want it to show for 7 days after the 25th so this part should be something like that : graph_date < cast(now() as date) -7 Link to comment https://forums.phpfreaks.com/topic/190464-date-sql-question/#findComment-1004672 Share on other sites More sharing options...
fenway Posted February 1, 2010 Share Posted February 1, 2010 You have to use - INTERVAL 7 DAY, not just "7". Link to comment https://forums.phpfreaks.com/topic/190464-date-sql-question/#findComment-1004826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.