Get all dates from previous month into excel

Hi Team,

I need to get all dates from previous month in the format “MM/dd/yyyy” and write same into excel

@sshitol,

Check the attached xaml
GetPreviousMonthDates.xaml (10.1 KB)

2 Likes

Hi
We can use DateTime.DaysInMonth method for this
The sequence of activities will be like
—use a assign activity like this
Int_days = DateTime.DaysinMonth(Cint(Now.Year),Cint(Now.Addmonths(-1).ToString(“MM”))
Where int_days is a variable of type int32 defined in the variable panel
—now use a WHILE LOOP activity like this
Counter < int_days
Where counter is a int32 variable defined in the variable panel with default value as 1
—now inside the loop use a WRITELINE activity like this
Now.AddMonths.ToString(“MM/dd/yyyy”)
—followed by this assign activity inside the while loop use a assign activity
counter = counter + 1

So this will display all the dates in the previous month
Cheers @sshitol

1 Like

Hi @sarathi125,

Your workflow is not working for this month that is january 2020.
can you help me

@sshitol,

Check the updated one,

GetPreviousMonthDates.xaml (9.4 KB)