DateTime.ParseExact(dateOfBirth.ToString,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)
Getting an error as cant convert date to string when i try to remove last to string value
Code should be like this
DateTime.ParseExact(dateOfBirth.ToString,“yyyy-MM-dd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)
Since format of date is yyyy-MM-dd
Hi,
Please store the output in a string variable instead DateTime variable.
This will resolve the error.
- If Input format is “dd-MM-yyyy” then use below code.
Str_Var= DateTime.ParseExact(StringInput.ToString,"dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")
- If Input format is “yyyy-MM-dd” then use below code.
Str_Var= DateTime.ParseExact(StringInput.ToString,"yyyy-MM-dd",System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")
Regard,
Ashutosh gupta
How do i add str_Var not allowing me
You need to create a string variable str_var for that @Arvind_Karthigayan
Try this @Arvind_Karthigayan
DateTime.ParseExact(dateOfBirth.ToString,{“dd-MM-yyyy","yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString(“yyyy-MM-dd”)
Regards
Sudharsan
And also i see in the screenshot that it should be in the format DD-MM-YYYY
So use this in type into @Arvind_Karthigayan
DateTime.ParseExact(dateOfBirth.ToString,{“dd-MM-yyyy","yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString(“dd-MM-yyyy”)
Regards
Sudharsan
Just remove "str_var = " from the Type this* box.
Cheers
Yes ofc @Arvind_Karthigayan
You can just remove the str_var= in the value field and use the expression
str_var is just for your reference and its like variable there,
If you want to parse the date in multiple formats you can use the expression i sent and if you have any other formats you just need to add them in the array of formats in the expression
DateTime.ParseExact(dateOfBirth.ToString,{“dd-MM-yyyy","yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString(“dd-MM-yyyy”)
Regards
Sudharsan
And also can you check this @Arvind_Karthigayan
I see here there is no comma inbetween g and { if you not have that add the comma there
And the formats should be separated like this
{“dd-MM-yyyy”,“yyyy-MM-dd”} and not like this {“dd-MM-yyyy,yyyy-MM-dd”} @Arvind_Karthigayan