Help required to change date format

Hello dears,

I am scraping data from an Arabic website, the date format pulled is in this format “YYYY/MM/DD” which I am facing difficulties to change afterwards in Excel, as I have to manually do several steps to put it in the correct format that I need.

Can someone suggest how to handle this case please? Basically I want it to be in “DD/MM/YYY” format before writing it to the Excel file at the end of my process.

Thank you.

Hello @Anwar_Mirza
Have you tried looking for this over forum? There are many solutions already available.

Once you read the Excel as DataTable, use a ‘For Each Row’ Activity and change the value of column you need
After this you can write.

Let me know if more help neeeded.

Not really, I am new to the forum. I shall give it a try now.

BIG Thanks to you brother.

Hello once again,

I just tried it and I am getting and error “Message: String was not recognized as a valid DateTime.” , I checked the data column type of my data table and it is a “String” format.

Do I have to change the data column type to “Date and Time” before implementing what you proposed plz?

Can you share the screenshot of your workflow OR the Date Example you are trying to convert

This is the screen shot

The date sample is 2021-03-09 (yyyy-mm-dd)

@Anwar_Mirza

Welcome to forums

Check below for your reference

Hope this helps you

Thanks

You probably forgot to type / after yyyy.

Now Date.ParseExact is looking for a format yyyymm/dd but in your initial question you said the input strings are in yyyy/MM/dd format.

I am assuming here that you have the correct datetime string codes which match with your input string.

It would also be good to include a data sample of your input string cause date time parsing need to be quite precise since for example an MM is not equal to mm and thereby the parsing might fail.

See here for date string codes:

You are doing some basic mistake.
If the Input is 2021-03-09 use,
DateTime.ParseExact(row("Issue").ToString(),“yyyy-MM-dd”,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

If the Input is 2021/03/09 use,
DateTime.ParseExact(row("Issue").ToString(),“yyyy/MM/dd”,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Month is denoted in capitals(MM)

GREAT!! It did work, Thanks a lot.

1 Like

Thanks for the help, I just noticed it.

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