0

I'm facing a strange error

I'm using the following line to parse string to date

DepartureDate = CDate("20" & year & "/" & month & "/" & day & " " & hour & ":" & minute)

And it work fine.

But sometimes I got the following error from my site page

Conversion from string "2013/04/14 18:15" to type 'Date' is not valid.

The string is right date,so why got this error.

The error stop when I restart the IIS

What happened to the IIS so it throw-ed this error???

and what shall I do to handle this type of error.

1 Answer 1

1

The error is probably because the culture settings change.

Instead of putting the components together in a string and then parse it, create a value directly from the components:

DepartureDate = New DateTime(2000 + year, month, day, hour, minute, 0)
Sign up to request clarification or add additional context in comments.

1 Comment

The occurre many times and stop when I restart the IIS and after a while it start again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.