Last week's number (-7 days from today)

How to get last week’s number in string or int format?

Ex : The current week number is 46 and expected output is 45

HI @Sathish_Kumar_S

Syntax: Now.adddays(-7)

Cheers!

One of many options

grafik

1 Like

Hi @Sathish_Kumar_S

Please try the following expression:

currentWeekNumber = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
                        DateTime.Now,
                        CalendarWeekRule.FirstFourDayWeek,
                        DayOfWeek.Monday)

And then, you check this:

If currentWeekNumber = 1 Then
    lastWeekNumber = 52
Else
    lastWeekNumber = currentWeekNumber - 1
End If

Hope this helps,
Best Regards.

cint(math.round(now.DayOfYear/7))-1

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.