Senior & Expert PHP Developers Discussion Forum by Nyros Technologies

HIRE PHP Expert Developers Programmers Coders From India
PHP .Net Ruby on Rails Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

Select result from multiple date ranges in mysql

 
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Help
View previous topic :: View next topic  
Author Message
aababu



Joined: 04 Jun 2008
Posts: 78

PostPosted: Thu Dec 17, 2009 3:57 am    Post subject: Select result from multiple date ranges in mysql Reply with quote

Hi friends,

I want a solution for how to get resutls from multiple date ranges, The actual requirement is users creates events in my site with multiple date ranges each event have mutliple dates see my tables structure below

I have the following data;
events
eventid title description
1 salsa salsa dance
2 party party for all

event_schedules
eventid start_date end_date
1 12-12-2009 15-12-2009
1 18-12-2009 23-12-2009
2 2008-01-17 2008-01-20

here in event_schedules table eventid is the reference from events table, I want a query for how to get today playing event. Ex: if today is 14-12-2009 how can i get the event from the date ranges that is playing today.

Thanks in advance
Back to top
View user's profile Send private message
venkatadapa



Joined: 12 May 2008
Posts: 280

PostPosted: Fri Dec 18, 2009 3:22 am    Post subject: Reply with quote

Try with this query
$cur_date = date('Y-m-d');
SELECT * FROM table WHERE (start_date=$cur_date or (start_date < $cur_date AND end_date >= $cur_date))

The above query will retrieve the results from db whose startdate = today or today is withing the dateranges.

Good Luck.,
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert PHP Developers Discussion Forum by Nyros Technologies Index -> Help
Page 1 of 1

 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts About foxycart
0 venkatadapa 5 Fri Jul 30, 2010 10:02 am
venkatadapa View latest post
No new posts How to change the mysql storage engine from MyISAM to innodb
1 aababu 10 Fri Jul 30, 2010 9:57 am
venkatadapa View latest post
No new posts How can we increase the execution time of a php script?
0 samir 6 Fri Jul 30, 2010 4:15 am
samir View latest post
No new posts Get no of days between two dates & current dates using M
0 samir 4 Fri Jul 30, 2010 4:09 am
samir View latest post
No new posts What are the different types of errors in php
0 samir 6 Fri Jul 30, 2010 4:00 am
samir View latest post
No new posts How to remove a value in an array using javascript
0 samir 10 Thu Jul 29, 2010 7:27 am
samir View latest post
No new posts Agile methodology plays vital role in software development
0 venkatadapa 7 Thu Jul 29, 2010 7:20 am
venkatadapa View latest post
No new posts How to get complete information about $_SERVER variable
0 Sanjana 15 Wed Jul 28, 2010 6:58 am
Sanjana View latest post
No new posts DNL Reader for php website
0 Mike 22 Mon Jul 26, 2010 12:33 pm
Mike View latest post
No new posts Use mysql_real_escape_string() function to avoid mysql injec
0 venkatadapa 26 Mon Jul 26, 2010 11:05 am
venkatadapa View latest post





Hire an expert PHP developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   .Net   |   Free unlimited HTML CSS Joomla Wordpress Drupal templates download

Nyros Technologies   |   Developers Blog   |   Kakinada City Portal   |   About PHP Experts   |   More