tags:

views:

27

answers:

1

I'm struggling to get week of year (from 1 to 52) in mysql query using friday as starting date. My friend said just add current date with number (because friday is 5 and sunday as default starting date is 0) 5 so that we can know week of year of given date.

What function will satisfy this problem? as for given that if value is 2009-12-28, it will ruin the function itself?

thanks before

A: 

i got a trick

select week(from_days(to_days('2010-01-01') + 2)) as week, '2010-01-01'

but if someone can give better answer, i will appreciate since i'm not sure about my method also if i give '2010-12-31' as answer, it's stuck

Miftah