ParseExact is not a member of a string

How to resolve this?

Uploading: image.png…

How to resolve this.

Hi @bhanupriya.cb ,

Do you have a variable created that has the same name as DateTime ?

HI @bhanupriya.cb

Try with this expression?

Split(DateTime.ParseExact("1/12/2023","d/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("d/MM"),"/")(0)

image

Regards
Gokul

Yeah, datecal is a variable name

You weren’t asked about datecal. You were asked about DateTime. It looks like you have a variable named DateTime. You should never create a variable with a name like this.

Also, why are you splitting? If you want the day do take /MM out of your ToString format.

DateTime.ParseExact(blah).ToString(“d”)

Yeah i dint observe it, i had created a datetime variable but i haven’t used anywhere in the expression… i removed the datetime variable and now it is working fine…

Note: I need to split only date because i want to select a date of single digit in date picker in some website so i have used that function to get only a date.

As I said, you don’t need to do the split. Just do…

DateTime.ParseExact(blah).ToString(“d”)

It’ll give you the exact same result but it’s less complicated.

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