[UPHPU] mysql date calculation bug

Jennifer Charrey jcharrey at xmtp.net
Tue Oct 16 15:52:06 MDT 2007


Why not just use a certain number of days instead of months as your 
intervals. Sure, some months are different lengths, but assuming 30 days 
  in a month should be fine for these purposes. So instead of going 6 
months back, where multiple starting dates might resolve to the same end 
date (like in the case of Sept. 28-31), just do 180 days back and you'll 
always get the same day. Same for your other intervals. Wouldn't that be 
a little simpler than trying to figure out if you already sent something 
in the last 5 days?

Jennifer



Jim Anderson wrote:
> initial looks tells me that the following won't work either. run the 
> following:
> 
> SELECT DATE_ADD('2007-02-28', INTERVAL 6 MONTH) + INTERVAL 49 DAY = 
> CURDATE();
> SELECT DATE_ADD('2007-03-01', INTERVAL 6 MONTH) + INTERVAL 45 DAY = 
> CURDATE();
> 
> those 2 queries both return true. notice, though, that they are 1 
> calendar day apart and 4 interval days apart. this is going to have the 
> same basic effect as before. :(
> 
> i think the least development time is going to run a check to see if the 
> email has been sent within 5 days and , if so, don't send it again. [5 
> days chosen as the largest margin of duplication, that i can see, is 4 
> days [february] but this would happen in any month begin/end cycle.]
> 
> i do like the brain storming though. feel free to keep up the ideas!
> 
> thnx,
> -ja
> 
> 
> 
> Ben Reece wrote:
>> Jim Anderson wrote:
>>> A good suggestion. I thought of that as well, but seem to remember 
>>> coming across similar issues. I've had about 15 things in my head 
>>> throughout the day so I may be getting some of my issues/projects 
>>> schmeared though. Do you think doing it that way would skip over 
>>> anyone? I saw that as an unlikely, but possible, concern.
>>>
>>> i was thinking something like:
>>>
>>> WHERE DATE_ADD(start_date, INTERVAL 6 MONTH) + INTERVAL 45 DAY = 
>>> CURDATE()
>>>
>>> but i haven't had the time to test it out.
>>>
>>> to fill out the scenario a bit fuller, the criteria is this:
>>>
>>> * 9 different emails. one for each of the following date scenarios.
>>> * six months after sign-up minus 45 days
>>> * six months after sign-up minus 30 days
>>> * six months after sign-up minus 15 days
>>> * six months after sign-up minus 5 days
>>> * six months after sign-up [minus 0 days]
>>> * six months after sign-up plus 15 days
>>> * six months after sign-up plus 30 days
>>> * six months after sign-up plus 45 days
>>> * six months after sign-up plus 60 days
>>>
>>> That is the schedule that i have in place.
>>>
>>> -jim
>> I don't see any problem with that statement -- seems like it would 
>> work without any problems.  The only possible issue would be that the 
>> emails might not be the exact number of days apart that you show, 
>> since you're adding months, and the date can move a little bit because 
>> of that.
>> Ben
> 
> _______________________________________________
> 
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net


More information about the UPHPU mailing list