Get date value as a string

Hello All,

I have an excel file that contains two different formats of date values i.e (“9/29/1980”, “10-11-1980”). It gives me out as respective for row is i.e (“9/29/1980”, “11/10/1980 00:00:00” ).
I want this row value as it that present in the excel row.

Thank!

@Pradumn_Chavan
welcome to the forum

not recommended and slowing down: check a run when preserve Format is activated on read range

Can you please mention step how to get data in preserve format.

grafik

If I tick preserve format debug process is continuously running it’s not showing me any output.

Row.fieldof(datetime)(“excelColumnNameWhereTimestampExists”).tostring

thats why gave the statemtent. In order to select an suggestion what is the motivations to keep it?

Needed to type as it is data that are present in excel file.

@pauloengenharia5 that means you are getting each row and typing it somewhere? Also, do you reading the data from excel to datatable

maybe better to get the data in excel with leading ’ like '10-11-1980
then excel is forced to keep it as text, preserve format can be unselected, the read range is not slowing down and the format / value is kept

Not working any of the solutions. Anyone has any idea for same.

for a RnD round manually adding the ’ in the Excel was not working?

Sorry, but I can’t understand what you are saying.

Perfect, but is a difference to

RnD Round - remove unneded rows and test it on a small set with data reflecting the different cases

  • open Excel
  • on the relevant cell add a ’ (single quote) befor the value
  • Save an close Excel
  • readin with with read range without the preserve format option and check the result within the datatable

A leading ’ will force Excel to treat the value as text and this will influence read range result

@Pradumn_Chavan Could you please explain the scenario a bit more. You are getting that date format from excel and are you trying to enter it somewhere

@Pradumn_Chavan You can loop through each row in data table and format that changed date value. did you try that ?

Yes, I tried that. But when I use to format it will take only one separate date field either " - " or " / ". But I want this date as a string like it that is present in the excel row.

Welcome to the UiPath Community forums @Pradumn_Chavan :partying_face:

Can I ask some more questions to clarify your requirements.

Input row value samples:
“9/29/1980”, “10-11-1980”

Currently writing values in excel as:
“9/29/1980” OR “11/10/1980 00:00:00”

What does your Expected Output look like?
“9/29/1980” OR “11/10/1980" OR something else?

Cheers

Steve

I want output like if the date in excel = “9-02-2022” then I want as it is “9-02-2022” same.
If date = “9/02/2022” then I want “9/02/2022”. When I take a date in uipath it’s changing this date separator.

HI @Pradumn_Chavan,
as already written the “PreserveFormat” property should do the job:


Output in debugger:
image

So not entered as DateTime in this case…