StudioX - Error reading a file and date support

Hi,
I’m on StudioX. I’ve an Excel file with 10 columns and 58 rows (including headers).
One of the columns is date and the data in the Date column is like this mm/dd/yyyy format.
I want to read the data from the Date column and add only the year to another column (e.g. if I have a date 03/12/2020 then i only need 2020 and write it to corresponding column / cell.)
I’m using For each row, then in Write Cell, I write year(CurrentRow(“Date”), it does not work. It shows 1905 for every cell. Can someone assist ?

Hi @Prinal_C …Could you please share any sample data to look at??

One idea i can think of is…you can use Right\Left and give / which will give 2020 if you read from right…

@prasath17 attached is the picture (sample). I want 2020, 2019 year in corresponding cell (Year column) in StudioX.

@Prinal_C - Could you please try this…it’s working for me…

Before this I have used “Use Excel file” activity

Code: Convert.ToString(CurrentRow.ByField(“Date”).ToString.split("/"c)(2).ToString)

Output

Please let me know, if this works for you. Initially I got the result in E2 as 2022 other rows are 1905 and some others date formats…later I fixed my sheet by coping the formats from D2 (which was working) to other cells …and it worked…

@prasath17 … Thanks. I’ll try your way. I’m wondering why wouldn’t =Year(CurrentRow.ByField(“Date of Track”)) work in Write cell?? This is a usual Excel function to get year from a date =Year(3/21/2020) should give 2020 in Excel.

@Prinal_C - that should work too… But as I mentioned even I too 1905. Where as the write line showed the perfect output. Then I fixed the data.

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