Calculate Week From March 1st

How can we calculate the week for current week , last week and last to Last week but Week no Start should change

For Example Week 1 : Starts on March 1st 2022

So accordingly the week No should be calculated for Current week , Last Week No and Second Last Week

Hi,

How about the following expression?

startDate = New DateTime(2022,3,1)
targetDate = New DateTime(2022,8,24)

Then

(CInt(Math.Floor((targetDate-startDate.AddDays(CInt(-1*startDate.DayOfWeek))).TotalDays)) \7)+1

If you need last week number and last second week number, try to subtract 1 or 2 from the above.

Regards,

1 Like

Any other approach

Hi,

Is there any problem?
What approach do you need?

Regards,

Actually I am getting Error could you share xml if possible.

HI,

Here you are.

Sample20220825-4.zip (2.3 KB)

Regards,

Thanks @Yoichi for your quick response

Regards,
@anmita

1 Like

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