Convert format string

I want to convert string as below.

variable Start as string = 25650131 (yyyyMMdd)
to full month —> 31 มกราคม 2565 (dd MMMM yyyy) → Month in thai name

please guide me about it.

1 Like

Hey @fairymemay

Kindly find the below,

Datetime.ParseExact("25650131", "yyyyMMdd", nothing).ToString("dd MMMM yyyy", New System.Globalization.CultureInfo("th-TH"))

Hope this helps.

Thanks
#nK

@Nithinkrishna

Output as wrong. (wrong year)
01 มกราคม 3108

Output that expected : 01 มกราคม 2565

Please guide me for solve it.

because 2565 is already Buddhist date, so we dont need to add 543 years again

try this

Datetime.ParseExact(startDatePeriod.toString, "yyyyMMdd", nothing).ToString("dd MMMM "+Left(startDatePeriod.toString,4), New System.Globalization.CultureInfo("th-TH"))

1 Like

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