Re: Modulo Arithmetic... for negative numbers

2004-08-19 Thread Richard Dyce
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

Re: Modulo Arithmetic... for negative numbers

2004-08-19 Thread Keith Ivey
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 archive

Modulo Arithmetic... for negative numbers

2004-08-19 Thread Richard Dyce
Hi, just an odd query. Background: I'm trying to calculate the Next Thursday and Next Friday dates from today (whenever that is), and return today's date if it's already a Thursday or a Friday. As a bit of a traditionalist, I've been used to modulo arithmetic always giving a positive answer, so