recurring date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jyoti.agarwal
Forum Newbie
Posts: 2
Joined: Fri Aug 28, 2009 6:35 am

recurring date

Post by jyoti.agarwal »

hi

i have a problem in recurring date.
i have a table event in which i stored start date,end date and daily,weekly,monthly recurring values if any.
just as in train schedule.
now i want to select all the values which recur at a particular date.
means i select a date from calendar
and query returns all the events of that day if they recurred on that day
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: recurring date

Post by Eric! »

How is the event date/time formatted in your database?

If you are using the standard SQL datetime format YYYY-MM-DD HH:MM:SS

Code: Select all

 $query = "SELECT Event FROM `TABLE` 
        WHERE date>'".$year."-".$month."-".$day." 00:00:00' AND date<'"
        .$year."-".$month."-".$day." 23:59:59' group by Event";
This will select from your "Event" field in TABLE where the "date" field matches the full 24 hour period of the selected $year-$month-$day from 00:00:00 to 23:59:59. You can make another query to join both start date events and reoccuring events.
Post Reply