How to change format month?

I have query as below.

Date_month = DateTime.ParseExact(date_1,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“MMMM”,culture)

Output = เมษายน ( local name month in TH language)

If I want to new 2 variable for year (2021) and month (04).
Please suggest about it.

I want edit from .xaml as below.

Main.xaml (13.2 KB)

Please guide me about it.

Use below part for getting month name in th language

Date_month=DateTime.ParseExact(date_1,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“MMMM”, System.Globalization.CultureInfo.CreateSpecificCulture(“th”)).ToString

Hi @fairymemay

Sorry for delayed response

See the answers

For day

Date_day = DateTime.ParseExact(date_1,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“dd")

Date_year= DateTime.ParseExact(date_1,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“yyyy")

Hope it helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like

@NIVED_NAMBIAR I use DateTime.ParseExact(date_1,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“yyyy”,culture)

But output show 2021 .

Please guide me for solve it.

Hi @fairymemay
i did not understand, what is the output u need finally?

@NIVED_NAMBIAR I​ want​ output​ year​ = 2564 ( B.E)​

Hi @fairymemay
do B.E need to be included ?

@NIVED_NAMBIAR I​ don’t​ understand​ you​ mean.

I tried and I got 2564 as result

@NIVED_NAMBIAR ???

image

Hi @fairymemay
this is result i am getting
image

used this below
DateTime.ParseExact(“29/03/2021”,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString(“yyyy”,culture)
replace the “29/03/2021” with the date_1
and culture should also be defined as below

Regards,
Nived N
Happy Automation

@NIVED_NAMBIAR Output as same.

Please guide me for solve it or send .xaml to me.

@fairymemay ,

Check like the following

CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(Convert.ToDateTime( date_1).Month)