Converting integer to date format in excel

Hello, I am trying to convert an integer “20190814” in excel to a date format in excel.
I tried using excel to convert it to a date format but it returns as “######”. Is there anyway where I can insert “/” or “-” between the yyyy-mm-dd ? Or is there any other way to do it?

Thanks in advance!

hi Kieran,
You can do it by:-
DateTime.ParseExact(inputInt,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

where inputInt is the string converted input of your value(in this case :-20190814).
ToString(“dd/MM/yyyy”) is the date as string representation in desired format .
Have attached the .xaml file for you reference as well…

Kind regards,
pankajConvertIntToDate.xaml (5.8 KB)

2 Likes

Thanks it work!!

Sorry to bother you again. But how may I convert the solution into a loop so that for each row in the excel column it would be converted?

hi Kieran,
You need to read the excel data first into datatable and then use for each loop to iterate for each value and use that value inside the above expression.

Kind Regards,
Pankaj

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