Date conversion to specific format

Hi everyone, i got struck in date conversion.
I have a Excel and it have some dates and i need to look for today date in that but I’m unable to match it. Can anyone help me

Code which I’m using is :
DateTime.ParseExact(CurrentRow(0).ToString, “MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

But this is not working it is throwing error like string is not valid date time

Input:

Hi @Rreddy -

Try this

DateTime.ParseExact(CurrentRow(0).ToString(), "M/d/yyyy", System.Globalization.CultureInfo.InvariantCulture)

Hi @ABHIMANYU_THITE1 getting same error like string was not recognised as a valid date time

Hi @Rreddy - can log there what value you received in the CurrentRow(0).ToString()

@ABHIMANYU_THITE1

@Rreddy

Can you try this way

DateTime.ParseExact(CurrentRow(0).ToString(),{"M/d/yyyy","MM/dd/yyyy","MM/dd/yyyy HH:mm:ss","MM/dd/yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture)

Hi @Shiva_Nikhil

Hi @Rreddy

Use this -

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

2 Likes

Thanks @ABHIMANYU_THITE1 it’s working.

1 Like

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