How to get 4 digit year?

How to get the full 4 digit year? For example, date of birth is 061439, how can I format this to get the 4 digit year? Thanks!

1 Like

Please explain your question.

Hi @Pal1831,



Good Morning,
061439 represents a date of birth. I need to convert the date to 06141939. I need to get the full 4 digit year which is 1939.

Another example
021214 - The full date for this is 02122014. I need to get the full 4 digit year which is 2014.


If my question is still not clear, I will try and clarify. Thanks

Hi @Pal1831,

Use DateTime.ParseExact

DateTime dateParsed = DateTime.ParseExact("061439", "MMddyy", System.Globalization.CultureInfo.InvariantCulture)

To extract the Year from above date use dateParsed.TOString("yyyy")

In case you are in need to go with specific culture, [en-Us or en-IN] follow the below links,

1 Like

I hope you have a great day!