Date in DropDown

Hello,

I want to get the yesterday’s date.

Using this.

Not all the time the date is in 2 digits. If it’s from 1-9, it’s only one digit.

My day format is this: Date.Now.AddDays(-1).ToString(“dd”)

image

Hi ,

Can you try by converting the String to Int format
Convert.ToInt16(Date.Now.AddDays(-1).ToString(“dd”)).toString

Mark as solution if this helps

Thanks.

Happy Automation :grinning:

Hello Priyanka,

Why is the tostring in red line?

image

The double quotes when you copy it wont come correctly , Please type them alone.

THANK YOU, PRIYANKA!

1 Like

How about in the month Priyanka? What if Today is September 1. But I want to get the yesterday’s date which is August 31. Using the dropdown to each month, day, year

Hi ,
Month = Date.Now.AddDays(-2).ToString(“MMM”)
Output: Sep

year = Date.Now.AddDays(-2).ToString(“yyyy”)
Output: 2020

Note: Used -2 to get the date of 31 august.

Is there other way that I don’t need to change it everytime, Priyanka?

I should run this everyday. And there won’t be any issues if we’re finding the recent month. However, if for example we’ll have to be in the 1st day of the month, the only issue is the month itself.

Like is it supposed to be always -2 in the month?

I’ll be running the bot everyday using yesterday’s date. For example it’ll be October1, and i’ll get the September 31. Then, for example it’ll be October 2, then i’ll get the October 1.

I don’t get the Question .
For the -2 , I used it to get the Answer as Previous month . Otherwise -1 can be Used Everywhere.

Month = Date.Now.AddDays(-1).ToString(“MMM”)
Output: Sep

year = Date.Now.AddDays(-1).ToString(“yyyy”)
Output: 2020

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