For Perl, take a look at the DateTime module. It provides a week() method that can return the week number of the year for a given DateTime object:
($week_year, $week_number) = $dt->week;
Please note that the year matters because the date may be a week for the previous or next year. This is because of the ISO standard for the "week" where the first week of the year is such that it is the fourth day of January. Thus, a date like January 1 may be in the last week of the previous year.
For an unprepared eye, it looks like the MySQL YEARWEEK() function can do the same, or Mikey1980 suggests , try the WEEKOFYEAR() function. It seems that YEARWEEK() does the same thing its documentation says:
The resulting year may differ from the year in the date argument for the first and last week of the year.
... but I cannot guarantee that they are doing the same. :-)
Canspice
source share