What is the best way to get the week from a date in the format 01 02 03 04 05 rather than 1 2 3 4 5?
The simplest method is to concatenate your leading 0
s and then taking the two rightmost values:
select right(concat('00', DATEPART(week, getdate())), 2) as WeekNum
You do not need a udf for this...