1

I have a problem which appears on windows7embedded 32bit but not on my windows10 64bit developing desktop. I run the exactly same code.

I have a variable as Date which contains date and time. Then I put it into a function as string. In the function I modify it while it is a string and then I convert it back to date again. This is where the error appears.

This is the format I use. Its always the format before I convert it:

dd.MM.yyyy hh:mm:ss

This is the function I use to convert the string, with the named format, into a date:

Dim d As Date

d = CDate(strDate)

Its one of my first posts, I still have my struggles with programming and thank you in advance.

  • Use [`Date.ParseExact()`](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.parseexact) or [`Date.TryParseExact()`](https://learn.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact) and pass that format as the second argument. – 41686d6564 stands w. Palestine Feb 21 '20 at 11:20
  • Thanks for you answer. I still get the error: _Conversion from string "25.09.2019 09:28:36" to type "Date" is not valid._ on the windows 7 embedded device. It works perfectly fine on my windows 10 maschine. – Fabio Moser Feb 21 '20 at 11:44
  • Please [edit] the question and include your new code. Also, please make sure it's a [repro]. – 41686d6564 stands w. Palestine Feb 21 '20 at 11:47
  • 1
    Could the problem be a simple date format issue? 25.09.2019 isn't a valid US English date, because 25 isn't a valid month. However, it is perfectly fine in Europe for example. Are you using the same locale for both systems? – gaccardo Feb 24 '20 at 13:44
  • @gaccardo I use the same format on the other system. both systems run on "dd.MM.yyyy" – Fabio Moser Feb 26 '20 at 14:04

0 Answers0