Error about datetime?

I want convert variable sheet1Date as string to datetime.
But show error.


My code below.

Please guide me for solve it

Instead of “dd/MM/yyyy” try “yyyy/MM/dd” in your expression.


1 Like

@poorna_nayak07 I have more question.
Now output show below.


sheet1Data and compareDate as Datetime

If I want format sheet1Date from 2021/05/16 to 16/05/2021

and compareDate from 05/16/2021 00:00:00 to 05/16/2021

Please guide me about it.

Bro Use this code
VaribleA=Convert.ToDateTime(YourString) VariableA type is System.DateTime

Convert the date to dd/mm/yyyy

I hope you will get the solution

Chethan P

Hi @fairymemay ,

By default when you try to print/store date value in a variable it will be in
MM/dd/yyyy HH:mm:ss format.

You can configure and print this by using expression compareDate.ToString(“dd/MM/yyyy”). Check below link for more details on DateTime to String


@poorna_nayak07 I​ don’t​ want​ change​ date​time​ to​ string.
But I want change​ format​ date​time​ from​ MM/dd/yyyy HH:mm:ss​ to​ dd/MM/yyyy​ HH:mm:ss

Please​ guide​ me​ for​ solve​ it.

The operation you are looking for is not possible. All date time values are stored in same default(​MM/dd/yyyy HH:mm:ss) format in DateTime Data type.
You can perform all basic operations( attached below) on datetime type.

Alternatively you can convert DateTime to any required String format and perform string operations.