How to compare the dates and fetch the month

How to fetch the previous month and year

Consider we have condition

if (currentdate < previous date)
{
print (yyyy/mm)
}

Ex: If (01-05-2021< 30-04-2021)
{
print (2021/04)
}

Hi @chaithanya_kumar_M

Please find the below method,

if(now.ToString(“ddMMyyyy”)>now.AddDays(-1).ToString(“ddMMyyyy”))
{
write Line: now.AddDay(-1).ToString(“yyyy/MM”)
}

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

Hi @vignesh.ks

Thanks for your support can you please help me out why am getting compiler error

@chaithanya_kumar_M
The condition is wrong, it should be

Now > Now.AddDays(-1)

Use the below Activity to get the previous month or year date

Hi @chaithanya_kumar_M

Please give like below.

image

Thanks.

Hi @vignesh.ks

Thanks for the support it works as expected but what ever the out put comes from writline am able to see in message box this is also perfect.

But this value am not able to pass inside my URL when i pass output it is taking empty value


image

1 Like

Hi @vignesh.ks

Works perfect thanks!!

Regards,
chaithanya

1 Like

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