Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.