Playing around with the date/time functions, I came up with:

select subdate(now(), INTERVAL weekday(now()) DAY);
select adddate(now(), INTERVAL 6-weekday(now()) DAY);

So once you have a date in the desired week, it's easy to calculate the
first/last days in that calendar week.

> -----Original Message-----
> From: Eric Jensen [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, July 13, 2005 12:52 PM
> To: mysql@lists.mysql.com
> Subject: Getting first and last day of week
> 
> Is there an easy way of finding the first and last day of a week?  I'm
> looping through week numbers, I.E. 2005-06-12 is week 23, but for
> display I would like to know the first and last day of that week.  I
> usually just loop through some days and find them myself, but I am
> curious to know if there is a more efficient way with MySQL.
> 
> Eric
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    
> http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 

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

Reply via email to