Re: date functions

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

 



> I want to use it in this function that i am creating (it's for a
resteraunt
> automated tips system, to work out how much tips each staff member is
> entitled to.
>
> ========================================================================
> function tips($weekstart){
> /* JUST BELOW HERE IS WHERE I NEED TO GET THE DATE OF 6
> DAYS AFTER THE
> SPECIFIED DATE OF THE START OF THE WEEK */
> $weekend = date($weekstart +6);
>
> $query = "SELECT * FROM Rota WHERE date => $weekstart
>                  AND date <= $weekend ORDER BY staffid";
>
> etc...

What format is $weekstart in? Maybe you said already, I can't remember.

You could try

$weekend = strtotime($weekstart . ' +6 days');

Since I think your 'date' column is a TIMESTAMP, you'll need to format
$weekstart and $weekend as YYYYMMDD in order to get what you have above to
work.

Maybe try this:

function tips($weekstart){
  $start = date('Ymd',strtotime($weekstart));

  $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start +
INTERVAL 6 DAY) ORDER BY staffid";

  etc...

---John Holmes...


-- 
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