Hi everyone I’m working on a some excel activities in that i have one date column when i try to convert that into specific format it is throwing error. Firstly I’m getting some data in excel i want to update that on web browser page in that date field i need to split it like day, month and year, I need to write in my browser filed but here my bot is throwing error that it is not a correct format I’m attaching the screenshots also.
This is my actual excel date format
My code
My bot is throwing error in convertion part
Srini84
(Srinivas Kadamati)
March 16, 2021, 6:00am
2
@ranaprathap928
Check below for your reference
If date is returning as number, then check below for your reference
Hope this helps you
Thanks
Hi @NIVED_NAMBIAR i tried that it is not working
@NIVED_NAMBIAR I’m getting this error in production when i test in normal flow it’s working. I need to some different code for coversion of date
are u getting error when u are using substring approach @ranaprathap928
@NIVED_NAMBIAR I’m getting error here
Converted date (assign activity)
@NIVED_NAMBIAR
This type error I’m getting in Converted date (assign activity)
Hi @ranaprathap928
so it implies that u are getting error for this date with format of dd-MM-yyyy only ?
is it right buddy?
Yes @NIVED_NAMBIAR few getting similar formats and few are getting different formats, that’s y i used this convertion activity there
Hi @ranaprathap928
I think u can refer this how you can convert multiple dates format into single one
string strDate = "04/23/2019";
string[] arr = {"MM/dd/yyyy","M/d/yyyy"};
DateTime dt = DateTime.ParseExact(strDate, arr, new CultureInfo("en-US"),
DateTimeStyles.None);
Console.WriteLine(dt.ToShortDateString());
The sample C# code works for me.
You must initialize the culture info object. Then only the array of formats will be considered and works.
Regards,
Karthik Byggari
Regards,
Nived N
Happy Automation
Thanks @NIVED_NAMBIAR i will check this
1 Like
@NIVED_NAMBIAR that is C# code I’m looking for any normal code, which can be understand easily.
Hi @ranaprathap928
Using assign activitiy
First create a string array
arr= {“MM/dd/yyyy”,“yyyy-MM-dd”}
Now use the below Assign activitiy
date_1= DateTime.ParseExact(strDate, arr, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
Regards
Nived N
Happy Automation
Ok @NIVED_NAMBIAR i will check this
1 Like
@ranaprathap928
Try below once
Just pass your date variable instead of date
DateTime.ParseExact(“02/27/2021”,“MM/dd/yyyy”, system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
@Pravin_Patil1 i will check this