Your request doesn’t really make sense. A date only has a “format” when it is converted into string. Otherwise it is a date which can already be compared. The only conditions are the cultureinfo settings (i.e. if you try to compare a US date with a UK date they won’t match all the time! :D)
Please send an example .xaml file of what you are trying to do.
I am using the data scraper wizard to get table values from a website and put it into a excel file.
My big problem is that UiPath gets the date fields in mm/dd/yyyy format but they are dd/mm/yyyy. How can I fix this? I dont know where to put Convert.ToDateTime(dt.ToString(“dd/MM/yyyy”)) into the data scraper.
It sounds like you said that on the website the dates are in “dd/mm/yyyy” format?
I think you need to treat it normally as a string and just write it in that format to Excel. You can change the default date format that your computer sees by going to Control Panel > Region and Language. Changing that setting will see the day and month in the correct spot.
However, if you don’t want to change your region and use the basic mm/dd format so you want to convert it then you would probably want to correct it line by line with a ForEach, or if you are processing each line one at a time you can do it within that loop.
You can use I believe
row(“Date”) = Date.ParseExact(“dd/mm/yyyy”,row(“Date”).ToString.Trim,System.Globalization.CultureInfo.InvariantCulture).ToString(“mm/dd/yyyy”)
You can also just treat it in reverse and reformat it like
row(“Date”) = CDate(row(“Date”).ToString.Trim).ToString(“dd/mm/yyyy”) which will flip the month to the date spot and date to the month spot
So in summary,
Either change your Default Regional Date Format for the computer or inside a ForEach reformat each date one by one.
There are also alternative ways with LINQ but was trying to be simple.
I managed to solve the problem inside the excel with vba, after the data scrapping.
Just to everybody with the same issue:
The big problem was that some dates imported as dd/mm and some as mm/dd. I realized that some of then were imported as text. Starting with this I wrote a macro that treated… used istext also used datevalue in the code.
Use below code it will work.
Mention the what specific format of your input and what format you are expecting. Date.ParseExact(“dd/mm/yyyy”,strDate.ToString.Trim,System.Globalization.CultureInfo.InvariantCulture).ToString(“mm/dd/yyyy”)
I got a bit problem in here.
I tried couple of codes about and they don’t work well in my case.
the date i scrapping from web like
it works with the first one.
and when it comes to the second it will not work.
however it will not work from the first one.
I also tried
seems work with the first one only.
I tried to reverse date and month to reformat the date uisng **w(“Date”) = CDate(row(“Date”).ToString.Trim).ToString(“dd/mm/yyyy”) but it is giving month as 00
I have a dt(variable) with format “dd.MM.yyyy”, and I want to use your method to convert it into a new format to"yyyyMMdd".
I tried with assign NewDT=Convert.ToDateTime(dt.ToString(“yyyyMMdd”)), system always come up with a complier error reminder.
Please help to take a look and help me on this.
What if I begin with a variable dt instead of today?
I tried both dt.ToString(“yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture) and DateTime.dt.ToString(“yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture), neither of them works.