Not able to get the date in (mm/dd/yyyy) format as it shows System.Globalization.GregorianCalendar

not able to get the date in (mm/dd/yyyy) format as it shows System.Globalization.GregorianCalendar.

@Karan28,

Change this mm/dd/yyyy to MM/dd/yyyy

Use the below code to convert the date format
Declare convertedDate as a datetime varible.
convertedDate = Convert.ToDateTime(“yourDateString”).Date

DateTime.ParseExact(convertedDate.ToString(“MM.dd.yyyy”), “MM.dd.yyyy”, Nothing).ToString(“MM/dd/yyyy”)

not working , could u please explain

@Karan28,

Could you please share your input datetime string sample value and the desired format to you want.

Hi @Karan28,

read this post:

GL with your project

yes ,

I an excel if If using dates like this - 05/14/2019 , means in a MM/dd/yyyy format I am getting error :-The DateTime represented by the string is not supported in calendar System.Globalization.GregorianCalendar.

In an input excel the dates should be in MM/dd/yyyy Format , but bot is not reading in that format
if I use dd/MM/yyyy format it works

@Karan28,

It is due to the system datetime format, why you need to convert it to a different format?

I need to get the input date from an excel in MM/dd/yyyy format and then change it to dd/MM/yyyy and use it in web automation to paste it in a ui field

yes i went through this post before but didn’t get the solution, Could u please help

Hi @Karan28

Try this one to change the date format.

DateTime.ParseExact(yourdate.toString(“MM/dd/yyyy”).ToString(),“MM/dd/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Regards,
Kommi Jeevan.

Thankyou Buddy , Found the another solution and worked

what is another solution? Can you please share?