To get Month from Date

Hello people,

following is the query,
VAR1= 30-07-2021 (type: Generic)

I Need to get month and year value from above variable in this format - " July’21 "

Can anyone please provide solution to this

Hi!

Regards,
NaNi

Hi

you can try this

DateTime.ParseExact(VAR1.ToString,“dd-MM-yyyy”,Nothing).ToString(“MMMM”)+“'”+DateTime.ParseExact(VAR1.ToString,“dd-MM-yyyy”,Nothing).ToString(“yy”)

Result is July’21

Thanks
John

Hi,

Can you try the following?

DateTime.ParseExact(VAR1.ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("MMMM\'yy")

Regards,

2 Likes

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