View Single Post

   
  #1 (permalink)  
Old 04-15-2008, 09:33 PM
lawpoop@gmail.com
 
Posts: n/a
Default week to date function

Hello all -

I have a site that is supposed to list a history of weekly reports.
I'm using the WEEK() function to find all distinct weeks in the
recordset. However, one I have my week numbers, there is no obvious,
handy way to convert a week and year to an actual date.

I was looking for something like WEEK_TO_DATE( WEEK, YEAR, WEEKDAY )
or WEEK_START_DATE( WEEK, YEAR) where you could get single date from
knowing a week and a year. Absent such function(s), what's the easiest
syntax to use to convert a week to a date? Given the year $year and
the week $week, something like

SELECT DATE_ADD( '$year-01-01', INTERVAL $week WEEK )

To get the first day of that week?
Reply With Quote