Skip to main content
January 14, 2008
Answered

Mysql Results for > 2 Days Ago

  • January 14, 2008
  • 3 replies
  • 278 views
Hi All,

I am making a site for a band and would like to have a section of the site that shows when their performances will be. I'd like this to show all upcoming events plus any events that have happened within the last 2 days.

Right now I have my mysql query set up with "WHERE Shows.show_date >= NOW()" and that works OK but is there a way to also pull the data for events from 2 days prior to NOW()?

I'm using mysql and php.

Thanks in advance for any help/suggestions you might have!
This topic has been closed for replies.
Correct answer Newsgroup_User
.oO(sfopp)

> I am making a site for a band and would like to have a section of the site
>that shows when their performances will be. I'd like this to show all upcoming
>events plus any events that have happened within the last 2 days.
>
> Right now I have my mysql query set up with "WHERE Shows.show_date >= NOW()"
>and that works OK but is there a way to also pull the data for events from 2
>days prior to NOW()?

Sure. Have a look at DATE_SUB()/DATE_ADD():

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add

Micha

3 replies

Inspiring
January 14, 2008
.oO(sfopp)

>Thanks Micha!
>
>That was exactly what I needed!

You're welcome.

Micha
January 14, 2008
Thanks Micha!

That was exactly what I needed!
Newsgroup_UserCorrect answer
Inspiring
January 14, 2008
.oO(sfopp)

> I am making a site for a band and would like to have a section of the site
>that shows when their performances will be. I'd like this to show all upcoming
>events plus any events that have happened within the last 2 days.
>
> Right now I have my mysql query set up with "WHERE Shows.show_date >= NOW()"
>and that works OK but is there a way to also pull the data for events from 2
>days prior to NOW()?

Sure. Have a look at DATE_SUB()/DATE_ADD():

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-add

Micha