String format to date

Hi @lakshmi.mp ,

Can you verify if there is space in your input?
Trim your input before converting/parsing the date (D_Format.Trim)

Hi!

I think @AnuSingh is right.

Could you please trim it and try the above mentioned expression.

Try it and let me know.

Regards,
NaNi

Hi @lakshmi.mp

Try this

Datetime.ParseExact(str_receive.trim,{“yyyy-MM-dd"," MM-dd-yyyy",“dd-MM-yyyy”},System.Globalization.CultureInfo.Invariantculture,System.Globalization.DateTimeStyles.None).ToString(“yyyy-MM-dd”)

Regards
Sudharsan

Hi,

I used trim (D_Format.Trim)


Getting error in conversion from string to type date.
str1 is of string type.
What changes i need to do.

Thanks,
Lakshmi

Hey!

The Expression is correct.

But you need to interchange the Else with then part and then part with else

This will works fine.

Try this and let me know

Regards,
NaNi

Hi @Sudharsan_Ka ,

Datetime.ParseExact(D_format.trim,{“yyyy-MM-dd"," MM-dd-yyyy",“dd-MM-yyyy”},System.Globalization.CultureInfo.Invariantculture,System.Globalization.DateTimeStyles.None).ToString(“yyyy-MM-dd”) => used this expression


Assign: String was not recognized as a valid DateTime.

Thanks,
Lakshmi

So can you show the displayed message box before the error? @lakshmi.mp

What you need to do is simply add the format in the array

If you d_Format is like 27.06.2022 format will be dd.MM.yyyy as like that if any other formats appears add that format in the array{}

Datetime.ParseExact(D_format.trim,{“dd.MM.yyyy”,“yyyy-MM-dd"," MM-dd-yyyy",“dd-MM-yyyy”},System.Globalization.CultureInfo.Invariantculture,System.Globalization.DateTimeStyles.None).ToString(“yyyy-MM-dd”)

Regards
Sudharsan

Hi @Sudharsan_Ka ,

Same error i am getting, I will share sample workflow and input file.
Please look on it.
Input formats will be changing but finally the date should be displayed in format MM-dd-yyyy
Op.txt (103 Bytes)
Sequence test.xaml (11.9 KB)
Please look on it.

Thanks,
Lakshmi

Just add this format in the array and check once

Use this expression

Datetime.ParseExact(D_format.trim,{“yyyy.MM.dd”,“yyyy-MM-dd"," MM-dd-yyyy",“dd-MM-yyyy”},System.Globalization.CultureInfo.Invariantculture,System.Globalization.DateTimeStyles.None).ToString(“yyyy-MM-dd”)

Regards
Sudharsan

Removal Date: 23.10.2021 i took this as input
getting this error: Assign: String was not recognized as a valid DateTime.
str_1 is string type right.

Regards,
Lakshmi

As per the format you need to add the format in the array as i said earlier

Add “dd.MM.yyyy” inside the curly braces{}

Regards
Sudharsan

1 Like

Hi,

Its working now. Thanks for providing the solution.

Thanks,
Lakshmi

1 Like