Jump to content

Date sql question


dannybrazil

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.