Re: SQL question
| From: | Kim Madsen | Date: | Tue, 26 Jan 2010 18:56:51 +0000 |
| Subject: | Re: SQL question | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-301485@lists.php.net to get a copy of this message | ||
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