Date = Row(“Date1”).ToString
DateTime.ParseExact(Date1.ToString().Trim(),“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”) → Throws Format Exception
WHEREAS
DateTime.ParseExact(“03/12/2021”,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MM-yyyy”) → Gives the output
Not able to understand what is that I am doing wrong here? Somebody please help. Thanks in advance!
ppr
(Peter Preuss)
April 13, 2023, 1:44pm
2
Jithesh_R
(Jithesh Karkera)
April 13, 2023, 1:51pm
3
@Anand_Parkash_Aggarwal ,
Can you import this and check once : System.Globalization
If its not working can you please show us your input “Date1” by printing it somewhere?
Regards
Hi @Anand_Parkash_Aggarwal , welcome to the Community.
We can see that you are assigning Row(“Date1”).ToString to Date, but inside the query, you are using Date1.ToString().Trim(), instead of Date.
Also, it will throw an error if the variable data that you pass inside the query doesn’t match with the format dd/MM/yyyy.
Hope this helps,
Best Regards.
How to install the dependecy?
I am unable to find it under Manage Packages.
Output of Date1 is like this
Jithesh_R
(Jithesh Karkera)
April 13, 2023, 2:03pm
7
@Anand_Parkash_Aggarwal ,
Not Manage Packages check below in “Imports”
Regards,
Added there. Still getting the same error.
Hi @Anand_Parkash_Aggarwal
Try this
Input date is of this format “MM/dd/yyyy”. So keep this format in the query.
DateTime.ParseExact(Date1.ToString().Trim(),"MM/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")
Still not working. Same error
@Anand_Parkash_Aggarwal What error you are getting. Can u share the screen shot.
Hi @Anand_Parkash_Aggarwal
Can u share the input file which you are using. May be it has different date format.
Hi @Anand_Parkash_Aggarwal
Give a try to this
DateTime.ParseExact(Date1.ToString().Trim(),"MM/dd/yyyy 00:00:00",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")
1 Like
ppr
(Peter Preuss)
April 13, 2023, 2:29pm
16
@Anand_Parkash_Aggarwal
Exactly for such scenario the FirstAid was aligned. Did you run the analysis statements / inspection steps as described within?
Found the issue. It is a formatting issue due to Excel. Thanks for the help guys
system
(system)
Closed
May 24, 2023, 5:57pm
20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.