Deep_HML
(Mariame)
November 4, 2022, 10:16pm
1
Hello ,
I have a date value retrieved from a text and the format of this value is not specific it may be “dd-MM-yyyy” , “dd-MM-yyyy” or other format ,i need to compare this value with a date value retrived from Excel this date is in this format “yyyy-MM-dd” so i tried to convert the first value into excel date format with the expression mentioned in the pic bellow but it deos not work.
Any help please ?
Thanks.
Yoichi
(Yoichi)
November 5, 2022, 12:33am
2
Hi,
It’s enecessary to set CultureInfo as 3rd argument like the following. Can you try this?
DateTime.ParseExact("2022-11-20",{"yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString
OR
DateTime.ParseExact("2022-11-20",{"yyyy-MM-dd"},System.Globalization.CultureInfo.InvariantCulture).ToString
Regards,
1 Like
s0biesky
(Raul)
November 5, 2022, 12:54am
3
Hi, it involves a bit of work but getting that date using regex may be a solution.
1 Like
Gokul001
(Gokul Balaji)
November 5, 2022, 4:42am
4
Hi @Deep_HML
Check out this expression
DateTime.ParseExact(YourString,{"dd-MM-yyyy","dd-MM-yyyy"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("yyyy-MM-dd")
Regards
Gokul
1 Like
HI @Deep_HML
You have missed
System.Globalization.CultureInfo.InvariantCulture
In your expression this should be added after adding the array of formats
Regards
Sudharsan
1 Like
system
(system)
Closed
November 8, 2022, 4:47am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.