Want date format from excel in a desired type of date format

i am reading an excel file where i have some dates which are in dd-mm-yyyy but i want this date format in “mm/dd/yyyy”
attaching ss for ref.

image

expected format

image

@ankur_kaushik2

Use format cells activity and format the excel column as you need

Or include a single literal before the date in eqch row so that it pastes the smae way
Eg: '12/12/2022 00:00:00

Cheers

Hi @ankur_kaushik2

You can use Replace syntax. Store the particular column values in an variable say str_billDate. Use the Syntax below:

Billdate= str_BillDate.Replace(“/”,“-”)

Hope it helps!!
Regards,

1 Like

do i need to install any specific package for tht because i am not getting “format cell” activity

Hi @ankur_kaushik2
You need to download UiPath.Excel.Activities to get Format Cell activity.

Regards,

getting these only

Hi @ankur_kaushik2
You get Format Cell activity in Modern excel activities and not in Classic activities.
Regards,

1 Like

Use the expression - DateTime.Parse(“dateinmm-dd-yyyy”).ToString(“MM/dd/yyyy”)

1 Like

why in some cases while reading the date i am getting as dd-mm-yyyy but in some cases its mm/dd/yyyy?

@ankur_kaushik2
You need to write an If condition for that.
Regards,

i gave it as “12/12/2022 00:00:00” but excel converted to “12-12-2022”

okay can you please tell me why this is happening?
i am in same excel sheet and same outputdt result variable but when iterating through the date its changing every time

@ankur_kaushik2

You missed the single quote that i placed infront of the date

12/12/2022 is wrong '12/12/2022 is correct

Cheers

1 Like

@ankur_kaushik2
Can you elaborate the error that you are getting with screenshots? So that it will help
Regards

reading this issue date column
image

and after iterating by for each i am getting values like this
image

if you match these both values from excels and log message both are different.

@ankur_kaushik2
If possible share the xaml file so that I can get an solution for you with the excel file.
Regards,

1 Like

dateformat.zip (13.0 KB)

@ankur_kaushik2

DateTime.ParseExact(dateST.ToString(),“dd-MM-yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”) Then I converted with this; Convert.ToDateTime(formattedDate)

thanks for reply but i cant use that,personal reasons

@ankur_kaushik2 Ok. so currently you are getting some data correct and some incorrect?