Date format error please help

hi,
I am reading the “Date” key from config file and pasting it" type into" activity- config(“Date”).to string but instated 31/01/2024 it is typing 12453 .
how should i convert it like 31/01/2024
my config file showing Date in this format-31-01-2024

1 Like

Hi @Hemant_Deshmukh,

Thanks for reaching out UiPath Community.

Can you try Convert.ToDate(Config(“Date”)).ToString("dd/MM/yyyy)

Hope this works for you.

Happy Automation,
@Vinit_Kawle

Hi @Hemant_Deshmukh

Can you try this

DateTime.ParseExact(config("Date").ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Cheers!!

it’s showing following error
23.12.0-beta.15287+Branch.release-v23.12.0.Sha.6f78cf34182e239b45fdde518f0d7807b8290d82

Source: Type Into ‘27/01/2024’

Message: String ‘45322’ was not recognized as a valid DateTime.

Exception Type: System.FormatException

Hi @Hemant_Deshmukh

Could you please share the screenshot of the config file and what is the flow you are doing so that I can help you out.

Regards


image

@Hemant_Deshmukh

Do not change the format in the config file. Keep the format in General only. Then it will work for you. You can give the below syntax directly in Type Into activity:

Config("Date").ToString

Hope you understand!!

no it still not working…now i change format to general as you said its showing like this and same in type into column activity.

Hi @Hemant_Deshmukh

Can you delete that entire row at type the same in next row.


From the above screenshot you can see that it’s accepting the date format.

After that in Type Into you can give below syntax to convert it to dd/MM/yyyy

DateTime.ParseExact(config("Date").ToString(), "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Regards

number looks like an OADate Double

grafik

We do see more often OAdate doubles within DataTables after an Excel read in when the Workbook Read Range is used.

We can prepare by e.g.

  • formatting the cell types in Advace before read range

But as we dont have a guarantee that not OADate, DateTime, or String is present within the resulting DataTable we would setup some defensive handling when we want to advance to a solid handling

23.12.0-beta.15287+Branch.release-v23.12.0.Sha.6f78cf34182e239b45fdde518f0d7807b8290d82

Source: Type Into ‘27/01/2024’

Message: String ‘01/31/2024 00:00:00’ was not recognized as a valid DateTime.

Exception Type: System.FormatException

Hi @Hemant_Deshmukh

Try the below syntax:

DateTime.ParseExact(Config("Date").ToString(), "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Hope it helps!!

1 Like

its working…Thank you so much bhai… :grinning:

1 Like

It’s my pleasure… @Hemant_Deshmukh

Happy Automation!!

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