Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Mysql Results for > 2 Days Ago

Guest
Jan 14, 2008 Jan 14, 2008
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!
TOPICS
Server side applications
281
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 14, 2008 Jan 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...
Translate
LEGEND ,
Jan 14, 2008 Jan 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 14, 2008 Jan 14, 2008
Thanks Micha!

That was exactly what I needed!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 14, 2008 Jan 14, 2008
LATEST
.oO(sfopp)

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

You're welcome.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines