Convert format date?

I have variable dateInput = 31/12/2020

I want to check each row from excel (column A) equal dateInput or not.
but CurrentRow format 12/31/2020 00:00:00

How to change format in currentRow?

Guide me about it please.

Hi @fairymemay

Please try this

DateTime.ParseExact(currentrow(0). tostring,“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

@prasath_S Now I use below.

DateTime.ParseExact(currentrow(0). tostring,“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”).Equals(dateInput)

It show error.

image

Is dateInput a datetime variable

If it is datetime variable

Convert.todatetime(DateTime.ParseExact(currentrow(0). tostring,“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)).Equals(dateInput)

@prasath_S dateInput a string variable.

Convert.todatetime(DateTime.ParseExact(currentrow(0). tostring,“dd/MM/yyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)).Equals(Convert.todatetime(dateInput))

try this and show what value is stored in dateInput variable

@prasath_S same error.

image

and what is value of currentrow(0).tostring

@prasath_S Value currentrow(0).tostring as below.

image

Hi @fairymemay
in read range check the preserve format option
image
then use below if condition : CurrentRow(0).ToString.Equals(dateInput)

OR another way is

to use below condition in if activity
DateTime.ParseExact(currentrow(0). tostring,“dd/MM/yyyy HH:mm:ss”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”).Equals(dateInput)

Try any way as mentioned above

Regards,
Nived N
Happy Automation

2 Likes

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