How to convert Dates of different format to a specific format

I receive the data via Google Sheet in that im having date column but the data filled in that column is different ways as below. I have to read that data and prepare a report in that the date format should be yyyy-MM-dd

  1. MM/dd/yyyy
  2. MM/dd/yy
  3. M/d/yy
  4. MM/d/yy
  5. M/dd/yy
    could you let me know how we can do this

Here is the format to convert @sunilch

datetime.parseexact(datestring,“dd/MM/yyyy”,system.globalization.culturalinfo.invariantculture).tostring(“required format here”)


Thank you for the reply i tried it but it will only work for the date format of “dd/MM/yyyy” but not for the other formats that i mentioned

I found one solution cDate(" your input date format").toString(“expected date format”). how ever it working for all except “dd/M/yyyy” format i’m searching whether we have any other function that can address this issue.

1 Like

Glad you got the solution. CDate will also work as expected in these scenario. both will work but you need to change the format inside everytime

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