Conversion of string into date format

Hello All,

I have this error when i convert the String 31-JAN-22 05:12 into date with this format 2022-01-31T05:12:00
it is working of some pdf files but not from five pdf
what means this error

Hi @nora_ziani,

Can you share code too ?

convert.ToDateTime("31-JAN-22 05:12").ToString("yyyy-MM-ddTHH:mm:ss")

My guess is that some of the pdfs you read do not have a space between the date and time. Can you print this value as a string before converting? In this way, you can also observe how the format changes.

example : 31-JAN-2205:12


I printed it it is like this
26-JAN-22 19:15

I used assign activity for row(2) like this
row(2)=Datetime.ParseExact(row(2).ToString.Trim,“dd-MMM-yy hh:mm”, System.Globalization.Cultureinfo.InvariantCulture).ToString(“yyyy-MM-ddTHH:mm:ss”)

best regards

row(2) variable type is string, correct ?

Additionally, don’t use trim here. It erases the space in between.For some characters this trim probably doesn’t do the job so it works, but on some reads it can see the space and delete it. If you want to remove the space you will get the same error.

I used it without Trim but still same problem :frowning:

Best Regards

You are getting an error because of the time zone. If you change 19 to 11, it will work correctly. :slight_smile:

To overcome this, update the assign as follows.

convert.ToDateTime(row(2).ToString, System.Globalization.Cultureinfo.InvariantCulture).ToString("yyyy-AA-ggTHH:dd:ss")

it is working thank you lot

Best regards !

1 Like

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