How to change the date format to another format

dear all,

i hava a date format in excel file like 2020/3/19 , how could i change the date format to 20200319?

anybody could give me some guide ? thanks a lot in advance.

Can you try by replacing the ‘/’ by ‘’ inside a for each row?

Or

By using Linq .

Can you try by replacing the ‘/’ by ‘’ inside a for each row? could u give me some demo?

  1. Read Excel File (With OutDT)
  2. For each row Activity (item in OutDT)
  3. Assign activity with row(“Datecolumn”) = row(“Datecolumn’).toString.replace(”/“,”")

You can use below code, @chrisjiyiwei
Datetime.parseexact( 2020/3/19,“yyyy/M/dd”,system.globalization.cultureinfo.invariantculture).ToString(“yyyyMMdd”)

1 Like

use this way, the result is 03192020 00:00:00 how to solve it?

how to use this way? could u give me some demo?

1 Like

Check this workflow, @chrisjiyiwei
Test_1.xaml (16.7 KB)

1 Like

@chrisjiyiwei: You can simply use the following line of code: (Replace string with string variable)

Convert.ToDateTime(“2020/3/19”).ToString(“ddMMyyyy”)

Cheers :+1:

2 Likes

Annotation 2020-03-26 153444

3 Likes

@Priyanka_Ramesh @chrisjiyiwei @Manish540 @Mohsin_Inamdar @Bhavik_Solanki

how to convert date in the format “DD-MMM-YY” OR “DD-MMM-YY” TO DD/MM/YYYY ?
example 26 March 21 to 26/03/2021 or 19 Feb 2021 to 19/02/2021

Hi @Sakshi_Jain,
Make an array of strings for the formats you will get
for example
String[] array_DateFormats = { “dd-MMMM-yy”, “dd-MMM-yy”};
then
str_OutputDate=DateTime.ParseExact(here_your_date.ToString(),array_DateFormats ,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)