Convert String (dd MMMM yyyy) to Datetime (MMM dd, yyyy)

Hello everyone,

I have a question about converting String format to Datetime.

For example:
before (String) → "31 June 2021
After (Datetime) → Jun 31, 2021

Could you help me?

1 Like

HI @brian_satijadi

Checkout this

DateTime.ParseExact(String variable,"dd MMMM yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("MMM dd, yyyy")

Regards
Sudharsan

1 Like

I think you cant make a format in date time @brian_satijadi

Regards
Sudharsan

DateTime.ParseExact(“31 June 2021”,“dd MMMM yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MMM dd, yyyy”)

the output is contains exception, can you help me to check the code above?

any idea for this case?

@brian_satijadi Type the date manually there and try once

@brian_satijadi

One bitter mistake :smile: june doesn’t have 31

Regards
Sudharsan

2 Likes

Hi @brian_satijadi

Just use the simple CDate expression

CDate("30 June 2021").ToString("MMM dd, yyyy")

image

Regards
Gokul

1 Like

oh i see hahaha, i’m so sorry… oke the final result is if the date isn’t contains in a calendar year, that data cannot coverted :+1:

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