Is sm.creation_date a DATE field or a DATETIME field? The problem is that if you insert a DATE into a DATETIME field, the TIME is marked as midnight of that date, so it would be *before* any times throughout the day. To fix it, we look for anything before the *next* day (which again, is midnight). Note that an "=" has been removed from line 10.
Even if it is just a DATE field, this will still work:
Main Topics
Browse All Topics





by: nemws1Posted on 2009-09-10 at 21:43:57ID: 25306732
Yes, WEEK() won't quite give you the results you want, since Aug 31 & Sep 1 are in the same week (namely, week 35). So we need to make sure we're also within the range of the first day to last day of the month as well. MySQL has a LAST_DAY function, but not a FIRST_DAY function, so we have a bit of extra work there (I'm still looking for a better way than this to figure that out).
This should work for you:
Select allOpen in new window