Date Format for year

i have one excel fine in that i have a date like 13/03/19 but i want dynamic year like 13/03/2019 if my year will 20 then it should take 2020 so in short currently i want date like 13/03/2019 in result.attach my excel sheet where i contain this date pls give me solution if u haveDatee.xlsx (13.9 KB)
Date.xaml (8.7 KB)

@sayli,

Try below one:

Datetime.parseexact(“13/03/19”,“dd/MM/yy”,system.globalization.cultureinfo.invariantculture).ToString(“dd/MM/yyyy”)

1 Like

ya but i want row(0) means for my total first column wise not static

@sayli,

In your excel, it is in second column.

So pass like this row.item(1).Tostring

And also it should be inside For Each Row

1 Like

@sayli,

Datetime.parseexact(row.item(1). Tostring,“dd/MM/yy”,system.globalization.cultureinfo.invariantculture).ToString(“dd/MM/yyyy”)

1 Like

Hi @sayli,

Refer the below workflow

Use an assign statement to put back the date to the excel

row(1) = DateTime.ParseExact(row(1).ToString,“dd/MM/yy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Date.xaml (7.0 KB)

1 Like

i just tried this at my end but the date formats in the excel don’t change

is it something that i am doing wrong?

@VirajN,

After changing the date format are you updating the datatable first with the updated date format and then using write range.

1 Like

i just downloaded your xaml file and connected it to the excel given by the OP.

Refer this file, its updated

Date.xaml (8.5 KB)

1 Like

i am feeling a little stupid now … i know i am missing something

Hi @VirajN,

Are you getting this error after running the above updated workflow.

Please provide your expression

i am running you updated workflow … not changed anything in that.

is it possible that in the original excel provided by the OP the dates are actually not in a date format but just a string?

Still error like String was not recognized as a valid DateTime

thanks working fine

1 Like

@sayli @anil5 now i am even more confused, how did it work for the OP but its not working for me :thinking:

Hi @VirajN,

Can you debug and tell me where exactly you are getting the error either in writeline or in assign statement.

Print row(1).tostring and see if there are any spaces in this

{
“message”: “Write Line Faulted”,
“level”: “Trace”,
“logType”: “Default”,
“timeStamp”: “15:28:51”,
“processVersion”: “1.0.0”,
“jobId”: “871ca05e-7038-4751-8ef7-b47e0d80c244”,
“robotName”: “Viraj N”,
“machineId”: *,
“fileName”: “Date (2)”,
“activityInfo”: {
“Activity”: “System.Activities.Statements.WriteLine”,
“DisplayName”: “Write Line”,
“State”: “Faulted”,
“Variables”: {
“date1”: “”,
“row”: “System.Data.DataRow”,
“dataeee”: “”
},
“Arguments”: {
“Text”: “”
}
}
}

Print row(1).tostring

Take a test sequence and run only the write line and provide the value “13/03/19” for row(1).tostring