Can someone kindly explain me why these two give different results?
I execute this with PHP.
date(\"YW\",mktime(0, 0, 0, 3, 22 , 2013)); // outputs 2
YEARWEEK takes a second (optional) parameter that specifies the range of the week [0- 53] or [1-53]).
This function returns the week number for date. The two-argument form of WEEK() enables you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range from 0 to 53 or from 1 to 53. If the mode argument is omitted, the value of the default_week_format system variable is used.
while date(W) is an ISO8601 date that is always in the range [01-53]. Therefore my guess is that by default YEARWEEK is using the [0-53] range.
So, if you want to get the same result try using 1 as the second parameter for YEARWEEK