Return week number for a year

How do I get the week number equivalent to Excel’s function ‘=weeknum(datenumber, 2)’ where the week begins on Monday?

Hi @gancw.

If this is still actual, you can try with the following Custom Script that will return current week number:

    output = 'week_number'

def WeekNumber() { 
		Calendar calendar = Calendar.getInstance();
		def WeekofYear = calendar.get(Calendar.WEEK_OF_YEAR);
		week_number = RNumber.of(WeekofYear)

Do not forget to create Recorder Variable week_number with type Number.

1 Like

Thanks Lera for the code. I have used an external Excel file as a work around and will switch to using this code instead.

BTW I found the documentation here