Please help, Date Format Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bernard

    #1

    Please help, Date Format Error

    Hello,

    Can someone please help me?



    We have developed a asp.net application which is working fine on 4 other
    computers. We have recently deplyed the application to the live environment
    running windows 2000 service pack 4, .NET v1.1.



    We continue to get the following error "Cast from string "18/07/2003" to
    type 'Date' is not valid." as the date is dmy and not mdy. We tried to
    change the server's regional settings to Australia. This did not fix the
    problem. We then tried to reinstall the framework. Still no luck.



    Is there some setting i have to change on the server or on the framework to
    use dmy date format?

    Below is an example of the asp.net source that is a corse of the problem.
    Please note that it is working on other servers and the work effort to
    change the code is not an option:



    Public Sub deletepdf(ByVal serverpath As String)
    Dim fd As System.IO.Direc toryInfo
    Dim fsArray As System.IO.FileI nfo()
    Dim i As Integer

    fd = New System.IO.Direc toryInfo(server path + "/Temp")
    fsArray = fd.GetFiles()

    For i = 0 To fsArray.Length - 1
    If (CDate(Format(f sArray(i).Creat ionTime, "dd/MM/yyyy")) <
    CDate(Format(No w(), "dd/MM/yyyy"))) Then
    fsArray(i).Dele te()
    End If
    Next i

    End Sub



    Please help me.



    Regards,

    Bernard.




  • Ravikanth[MVP]

    #2
    Please help, Date Format Error

    Hi

    First use the IsDate function to determine if date can be
    converted to a date or time.

    Ravikanth

    [color=blue]
    >-----Original Message-----
    >Hello,
    >
    >Can someone please help me?
    >
    >
    >
    >We have developed a asp.net application which is working[/color]
    fine on 4 other[color=blue]
    >computers. We have recently deplyed the application to[/color]
    the live environment[color=blue]
    >running windows 2000 service pack 4, .NET v1.1.
    >
    >
    >
    >We continue to get the following error "Cast from[/color]
    string "18/07/2003" to[color=blue]
    >type 'Date' is not valid." as the date is dmy and not[/color]
    mdy. We tried to[color=blue]
    >change the server's regional settings to Australia. This[/color]
    did not fix the[color=blue]
    >problem. We then tried to reinstall the framework. Still[/color]
    no luck.[color=blue]
    >
    >
    >
    >Is there some setting i have to change on the server or[/color]
    on the framework to[color=blue]
    >use dmy date format?
    >
    >Below is an example of the asp.net source that is a[/color]
    corse of the problem.[color=blue]
    >Please note that it is working on other servers and the[/color]
    work effort to[color=blue]
    >change the code is not an option:
    >
    >
    >
    >Public Sub deletepdf(ByVal serverpath As String)
    > Dim fd As System.IO.Direc toryInfo
    > Dim fsArray As System.IO.FileI nfo()
    > Dim i As Integer
    >
    > fd = New System.IO.Direc toryInfo(server path[/color]
    + "/Temp")[color=blue]
    > fsArray = fd.GetFiles()
    >
    > For i = 0 To fsArray.Length - 1
    > If (CDate(Format(f sArray[/color]
    (i).CreationTim e, "dd/MM/yyyy")) <[color=blue]
    >CDate(Format(N ow(), "dd/MM/yyyy"))) Then
    > fsArray(i).Dele te()
    > End If
    > Next i
    >
    >End Sub
    >
    >
    >
    >Please help me.
    >
    >
    >
    >Regards,
    >
    >Bernard.
    >
    >
    >
    >
    >.
    >[/color]

    Comment

    Working...