How to loop date?

I want loop date from today -count day format (“yyyy/MM/dd”)

variable count = int

Example count = 4
Today = 2021/05/18

I want datetime show 2021/05/13

Now I use DateTime.Today.AddDays(-count).ToString(“yyyy/MM/dd”) but show error.

Please guide me for solve it.

this might help

Good Morning,

Please mark your answer if solved.
To add or remove days from your declared date, you need to keep all of the variables as type datetime. Later on you can convert it in ToString and use it elsewhere.

1 Like

@fairymemay ,

Check like this, then you will be able to loop based on the date range.

1 Like

@sarathi125 If I want use 5 but I want to use variable count.


Please guide me about it.

Hi @fairymemay
I am able to use this expression

and got the result as expected

Do u want to use variable count inside the loop

1 Like


Change the -5 with your Variable as below

1 Like