How to convert Dec-21 into 31.12.2021

I have a scenario i need to convert Dec-21 into 31.12.2021? How to convert
Thanks in advance

Hi,

Can you try the following expression?

DateTime.ParseExact("Dec-21","MMM-yy",System.Globalization.CultureInfo.InvariantCulture).AddMonths(1).AddDays(-1).ToString("dd.MM.yyyy")

Regards,

1 Like

Hi,

Is that day 31 always we have to keep the same number? since we dont know what is the day for Dec-21 right. thanks

I want to read & change dynamically, directly from excel sheet ?

Hi,

If we use ReadRange or ReadCell activity with Preserve Format option, the above will work.
However, without this option, these activities read it as datetime style.
So if you can share specific example, we can suggest for your question.

Regards

This is the sample excel sheet, i have to read billing date column and convert the date
image

Hi,

Is your data in the worksheet text or datetime? if it’s datetime, we don’t need to use DateTime.Parse or ParseExact method. If possible, can you share your xlsx file? It’s no problem if dummy data.

Regards,

Use one of the conversions mentioned from above and parse it to the first of month.
With following method you can flexible calculate the last day of month

grafik

 CDate("December 2021")
 [12/01/2021 00:00:00]
 CDate("December 2021").AddMonths(1).AddDays(-1).toString("dd.MM.yyyy")
 "31.12.2021"
 CDate("October 2021").AddMonths(1).AddDays(-1).toString("dd.MM.yyyy")
 "31.10.2021"
 CDate("February 2021").AddMonths(1).AddDays(-1).toString("dd.MM.yyyy")
 "28.02.2021"

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