How to convert date format?

Hello,

i have dates format in like below - yymmdd

i need to convert each date in below format
01-Dec-25

how can i achieve this

Hi @Kamble_Shamaly

You can convert through :slight_smile:
outputDate = DateTime.ParseExact(inputDate, “yyMMdd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yy”)

Or

DateTime.ParseExact(inputDate,“yyMMdd”,Nothing).ToString(“dd-MMM-yy”)

Happy Automation

Hi @Kamble_Shamaly

Welcome to the Community

Please use this formula

=TEXT(DATE(2000+LEFT(A1,2), MID(A1,3,2), RIGHT(A1,2)), “dd-mmm-yy”)

Thanks & Happy Automations

@Kamble_Shamaly

If you have this data in an Excel use Format Cells activity to format the column to format - dd-MMM-yy

If you have this already in a string variable, use this LINQ

outputDate = If(String.IsNullOrWhiteSpace(inputDate),
                inputDate,
                If(DateTime.TryParseExact(inputDate, "yyyyMMdd",
                                          Globalization.CultureInfo.InvariantCulture,
                                          Globalization.DateTimeStyles.None,
                                          dt),
                   dt.ToString("dd-MMM-yy", Globalization.CultureInfo.InvariantCulture),
                   inputDate))

getting below error
image

Try this

DateTime.ParseExact(inputDate.Trim, “yyyyMMdd”, CultureInfo.InvariantCulture)

Hi @Kamble_Shamaly
Use linq expression for the date format for your regarding issue,

dtInput.AsEnumerable().
ToList().
ForEach(Sub(r)
r(“DateCol”) =
DateTime.ParseExact(
r(“DateCol”).ToString,
“yyMMdd”,
System.Globalization.CultureInfo.InvariantCulture
).ToString(“dd-MMM-yy”)
End Sub)

Make it in assign and use it.

it is converting like below

not as expected

how to make it in single line.?

@Kamble_Shamaly

simplest way would be just click on Fix button over there or here is one liner

If(String.IsNullOrWhiteSpace(inputDate), inputDate, If(DateTime.TryParseExact(inputDate, "yyyyMMdd", Globalization.CultureInfo.InvariantCulture, Globalization.DateTimeStyles.None, dt), dt.ToString("dd-MMM-yy", Globalization.CultureInfo.InvariantCulture), inputDate))

Make sure you have these variables created

Test Output

@Kamble_Shamaly

as you need the format in excel use format cells activity and give the format you need

you dont need to read or use linq or anything

cheers

yes i did it and working only issue is we have much data like 1 lakh rows so taking time.
u have provided one more way

If you have this data in an Excel use Format Cells activity to format the column to format - dd-MMM-yy

here i i have not understood what is data in an excel use?
is it will convert whole column in one go?
please help on same

@Kamble_Shamaly

yes it would convert whole column in one go

in input give excel.sheet("Sheetname").Range("A:A") change A to any column you need

if for visual purposes then in excel formatting is to be changed

cheers

Try this
outputDate =
If(
inputDate.Contains(“-”),
DateTime.Parse(inputDate).ToString(“dd-MMM-yy”),
DateTime.ParseExact(inputDate, “yyyyMMdd”,
System.Globalization.CultureInfo.InvariantCulture
).ToString(“dd-MMM-yy”)
)

what i need to select here

i need below format

01-Dec-25

@Kamble_Shamaly

you need to select custom and give the format

d-mmm-yy

cheers

@Kamble_Shamaly

Select the category as Custom and then use this format - dd-MMM-yy

Hi @Kamble_Shamaly

Use this expression to convert yyyyMMdd → dd-MMM-yy:

DateTime.ParseExact(er_create, “yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yy”)

Example: 20251201 → 01-Dec-25.

Hi @Kamble_Shamaly

Your value is in yyyyMMdd format (example: 20251201).

Use this expression:

DateTime.ParseExact(dateStr, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture) _
        .ToString("dd-MMM-yy")

Example:

  • Input: 20251201
  • Output: 01-Dec-25

:backhand_index_pointing_right: Use this in Assign / Write Cell / Output where dateStr is your string.

Regards,
Gokul