Thanks Keith!

About 5 minutes after I posted it, I had a personal email from someone suggesting exactly(!) the same thing. For the record, my reply:

On 19 Aug 2004, at 21:39, Richard Dyce wrote:

Thanks!

I'd got to go with:

   if(weekday(d)<4,3-weekday(d),10-weekday(d)) day)

which is I suppose the same thing, but not as elegant! And it makes the full calc look really awful!

select d, dayname(d) as day, date_add(d, interval if(weekday(d)<4,3-weekday(d),10-weekday(d)) day) as nextThurs from mydates;

Kicking myself,

However, in your honour (and as a reminder to myself to think first, post second), I'll kick myself again. ;-)



On 19 Aug 2004, at 21:52, Keith Ivey wrote:

Richard Dyce wrote:

mod(3-weekday(curdate()),7);

But MySQL doesn't seems happy to give back negative numbers:

What about changing it to MOD( 10 - WEEKDAY( CURDATE(), 7 ) ) to avoid the negative numbers?

--
Keith Ivey <[EMAIL PROTECTED]>
Washington, DC


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to