Re: schedule events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Apr 2003, josemaria wrote:

> Hi everybody,
>
> My question is pretty easy, so i hope the answer too :)
>
> Here it comes, I am programming an online schedule, and I need to know at a
> certain moment, how many events can occur, for instance, how many tasks to
> be done at 9:00 am, with the problem that users can insert tasks selecting
> hour and minute of start and end time, for instance, item1 takes from 8:00
> to 9:50, item 2 from 8:45 to 9:10, so at 9:00 it should return 2 items
> concurring...
>
> Thanks in advance for any help,
>
> josemaria sala

 Just make sure that your start and end times are in unixtime (seconds from
 1/1/1970) or that you convert to it.

 Example 1:
    start int(11) (unixtime)
    end int(11) (unixtime)

    select count(*) from table where start>=unix_timestamp() and end<=unix_timestamp();

 Example 2:
    start datetime
    end datetime

    select count(*) from table where unix_timestamp(start)>=unix_timestamp() and
    unix_timestamp(end)<=unix_timestamp();

 I'm not sure if this works if it is a datetime format, but it might:

    select count(*) from table where start>=now() and end<=now();


Peter
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux