REVERSE/FLIP Date and Month on Datetime Problem

Hallo,

I have to read excel date paramater.
When i read with no modification (Just Read Range Activity), the output was “12/30/2023” so the first output you get in the format “MM/dd/yyyy”.

How to:
get the correct format (reverse from your original one) from “MM/dd/yyyy” to “dd/MM/yyyy” in a string output? Thank you for the help

Hi @llayla

Try this:

originalDate As String = CurrentRow("your Column name").ToString
convertedDate As String = DateTime.ParseExact(originalDate, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Hope it helps

Hey @llayla ,
You can use the following function in the assign activity:

UpdatedDate = DateTime.ParseExact(dateVar.ToString,“MM/dd/yyyy”, Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))

Here, dateVar is the variable in which your date of format MM/dd/yyyy is store.

Hope this helps

Also refer below thread

HI @llayla

Store the value of date from excel in a Variable called ExcelDate

- Assign -> ExcelDate = Currentrow("Column name").toString

- Assign -> FormatDate = DateTime.ParseExact(ExcelDate,"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

The FomatDate is a Variable which stores the format date in dd/MM/yyyy

Hope it helps!!

@llayla

  1. If the format is correct in excel…then you can use read range with display format or preserve formatting options and it shpuld be read as expected
  2. If you want to change the format after reading into datatable then use this in invoke code by sending the dt as in/out argumnetdt.AsEnumerable.ToList.ForEach(Sub(r) r("Date") = Cdate("Date").ToString("dd/MM/yyyy"))

Cheers

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