Re: SQL question

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

 



Michael A. Peters wrote on 26/01/2010 06:04:

I use seconds from epoch in the database simply because it works so well with the php date() function.

If you need something where Julian day really is better, I assume it isn't that hard to convert between posix and julian day, though it seems odd to me that it isn't part of the date() function. It probably should be.

When I do date comparisons in MySQL I use the to_days() function.

> What I need to do is come up with a query that will determine if the start_date + no_donations falls within $start and $end.

In the given example one could determine that a month is always 30 days and then say to_days(start_date)+(no_donations*30) < to_days(end). This would however be a very loose method. You could go for finding the number of days in the current month and substract that (10th. = 30-10), play with MySQLs left() function

But Skip, as the others say, use a date class, since you're passing a php var on to the SQL anyway, then you could determine the exact days from start to end of donation. Combine this with to_days and you have your solution

--
Kind regards
Kim Emax - masterminds.dk

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux