0

We are running .NET 2.0 ASMX web services on Windows 2003 server on IIS 6.0. We have migrated a legacy VB 6.0 application to .NET 2.0 application using VB.NET. CDATE function is used at many places and we did not replace that with .NET equivalent date functions. After migration, code was working fine for many years.

Recently, we have started encountering issues on our production servers where the below code fails:

CDATE("11 Jul 2011 21:10:27")

Error: Conversion from string "11 Jul 2011 21:10:27" to type 'Date' is not valid.

If we perform an iisreset, the same code starts working fine. Could this be due to some recent patch for Windows server/ .NET patch?

Please help us to resolve this issue.

Thanks, Gayathri

  • Sounds like a problem with regional settings. Maybe this article is relevant:- http://stackoverflow.com/questions/1059930/a-better-cdate-for-vb6 – Nick Ryan Jan 10 '12 at 10:54
  • I don't think its related to regional settings since the same code works fine after IISRESET – ng-gayathri Jan 10 '12 at 11:19
  • Do you have any code in your application that sets the current culture? If you set the CurrentCulture property on the current thread it will affect this kind of operation and an IISReset would fix it until the code was invoked again. – BenR Jan 10 '12 at 13:42

1 Answers1

0

You can try converting them to something like this:

    Dim dateString As String = "11 Jul 2011 21:10:27"
    Dim pattern As String = "dd MMM yyyy HH:mm:ss"
    Dim result As Date = Date.ParseExact(dateString, pattern, Nothing)

Check this out MSDN ParseExact for more information. Although, that doesn't explain what may have changed.

Jay
  • 5,897
  • 1
  • 25
  • 28
  • Thanks for sharing this info. This might be alternate solution for the issue. I would be interested to know the cause of the issue. It happens periodically but after IISRESET, it works perfect. – ng-gayathri Jan 10 '12 at 11:24
  • Yeah, I agree its odd as I have no issues using cdate as long as the region settings on my machine don't change. (I am not using Server 2003 and IIS6 though) – Jay Jan 10 '12 at 11:25