Date format required VB Code

I want to convert date type to YYYYMMDD format from "Fri, 07 Jan 2022 01:03:24 -0600" this format. please hlep me


Welcome back to our UiPath community.

Try below expression.


Here, varDate holds your DateTime.

Hi @Sudheer_Kumar_S ,

Since the date is in a Proper DateTime acceptable format. We must be able to use CDate to Convert to Date and Convert it to Required String format using the below Expression.

CDate(" Fri, 07 Jan 2022 01:03:24 -0600".Trim).ToString("yyyyMMdd")

Alternate would be to Specify the exact format the input date is in as below :

DateTime.ParseExact(" Fri, 07 Jan 2022 01:03:24 -0600".Trim,"ddd, dd MMM yyyy HH:mm:ss K",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyyMMdd")

Note that trim is used to Remove Trailing and Leading Spaces in input string