Convert a string to datetime issues

Hi guys,
I tried to convert this string “08/11/2019” to a datetime to compare it to now.datetime with convert.todatetime(“string”) but that doesnt work (string to datetime conversion not allowed).

Some idea? :sob:

Hi @Farid,
Why not convert datetime to string and compare two strings? It’s easier :wink:

If you know the format, you can use Datetime.ParseExact(“String”,“format”) :slight_smile:

How can i compare datetime with this methods?

string1 > string 2

image

You also need to provide an IFormatProvider or Nothing.

Datetime.ParseExact(“String”,“format”,Globalization.CultureInfo.InvariantCulture)

OR

Datetime.ParseExact(“String”,“format”,Nothing)

yep, it was I did but the string is not recognized as a valide datetime ':frowning:

“08/11/2019"

i have tried the below and it works fine

datetime.ParseExact(“08/11/2019”,“MM/dd/yyyy”,Nothing)

I assume iDate is being stored as a String Variable date = “08/11/2019”

1 Like

xD

if you use Nothing like my example, my output datatime is this - 08/11/2019 00:00:00 (datetime variable)

I really dont know why it isn’t working for me xD

  • idate = datetime.ParseExact(“08/11/2019”,“MM/dd/yyyy”,Nothing)
  • write: idate.ToString

In your imports , do you have System.Globalization

Also idate is variable type System.Datetime?

1 Like

Can you post your XAML here? I’m guessing it has to do with your variable types. idate is a system.datetime variable correct?

1 Like

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