I am using “dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture. This result has been assigned to a DateTime Variable. EX: Output for the above is like 08/06/2019

I wanted the output to be 08062019. I wanted to remove “/”.
If i remove the “/” its displaying as - String was not recognized as a valid date time. Help needed.


Good morning Robotics,

Give this a shot:


1 Like

@Robotics - It looks like you’re talking about DateTime.ParseExact in the top portion, is that true? If so, then you need to make sure the “dd/MM/yyyy” is matching the string that you receive . Then, once you have your own datetime, when you want to output that as a string, you change it to the format you want in your output. So you’d say MyDate.ToString(“ddMMyyyy”)

1 Like

Great point Dave.

If the string is already in that format Robotics, you may also be able to use the replace function to just clear out the slashes.


you were almost done
datetimeoutput = Datetime.ParseExact(in_date,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

now datetimeoutput is a datetime variable with output as 08/06/2019 00:00:00

if we want in this format 08062019 we need to convert it to a string just a small additon to your expression

Stringeoutput = Datetime.ParseExact(in_date,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(ddMMyyyy)

now the output will be of type string like this “08062019”

simple isnt it
Cheers @Robotics

@ chenderson thanks for your simple solution

1 Like

Sir, I hope get some enlightenment from you because I am trying to convert a string (ddMMyyyy) to a datetime but failed.

The string split from a file name (eg: Sp_12112019.eml) I managed to assign the “12112019” portion into a separate string called str_date, then when I tried to convert it into a dateTime format, I cannot find a way out.



@Victor_Victory - A few issues here:

  1. your error suggests you are trying to convert a variable called string2 into a datetime. You said the separate date string is called str_date so you should double check that you are converting the correct variable.

  2. The date “12112019” (assuming November 12, 2019 correct me if I am wrong) is in the format “ddMMyyyy” so make sure that is the format you specify in your datetime.ParseExact activity.

If that doesn’t solve the issue, please use a write line activity immediately before the error occurs to display the string and verify it is indeed “12112019” like you are expecting.

If possible can I have a view on the expression you have used for conversion
Cheers @Victor_Victory