How to Convert any format Date(String Variable) into YYYYMMDD format

I am trying to convert the date which comes in String format into standard YYYYMMDD format. Can anyone please help.
Actually I am not sure in which format Business team will update the data in Input file, Hence whatever will be the format that string needs to be convert as YYYYMMDD.

Most common received format:
dd-mm-yy (e.g.: 25-Apr-22)
MM/DD/YYYY(e.g.: 4/25/2022)
YYYY-MM-DD(e.g.: 2022-04-27)
yyyymmdd (e.g.: 20220421)
DD.MM.YYYY (e.g.: 21.02.2022)

Some other rare formats:
YYYY MM DD (e.g.: 2022 09 01)
DD/MM/YYYY (DD M YYYY) - eg: 16/03/2022 (16 March 2022)

1 Like

Hey @nilesh.mahajan

What is your timezone your using please ?



Check below thread for your reference

Hope this will help you


Is there a standarization possible here? Like Bussiness team need to follow one particular date format. Are these datas generating manually or through some tool?

India Standard Time

No, Business team is not ready to make it standard, client is God for them… :grinning:

Hey @nilesh.mahajan

You need to do DateTime.Parse function by passing date string and IST culture format.

Please try and let us know


Hello @nilesh.mahajan ,

:grinning: DateTime.parse can work but you will have to dynamically provide the format.

working with dateTime.ParseExact method and using an array with the different formats can be checked: