CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: isDate problem

  1. #1
    Join Date
    May 2001
    Posts
    15

    isDate problem

    When I use isdate("31/04/01") it is interpreting
    as '01/04/1931" and returned true.
    Is there any way to interpret it '31/04/2001' when
    we give 2 digit year and return false.
    In SQL Server this is interpreted correctely.
    tHANKS FOR ANY SUGGESTIONS





  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: isDate problem

    Check the date format in control panel - Regional settings

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2001
    Posts
    15

    Re: isDate problem

    Regional Settings have Short Date Format as
    m/d/yy which is correct
    Any more suggestions please


  4. #4
    Join Date
    Apr 2000
    Posts
    737

    Re: isDate problem

    I think you can just write a function to check it yourself.

    first step : break the string into 3 token, where the "/" is the delimiter.

    second step : convert tokens into integer value

    third step : verify date, using day, month & year.

    all of the required function can be found in http://vblib.virtulave.net

    I enclose an example here, but u need to download the function.


    Dim s as string
    Dim sday as string
    Dim smonth as string
    Dim syear as string
    Dim day as Integer
    Dim month as Integer
    Dim year as Integer


    s = "31/04/01"

    vbstrings.Tokenize s, Asc("/")
    sday = vbstrings.GetToken
    smonth = vbstrings.GetToken
    syear = vbstrings.GetToken

    day = Val(sday)
    month = Val(smonth)
    year = Val(syear)

    If year < 100 then
    year = year + 2000
    End If

    Debug.print vbdatetime.IsDateValid(day, month, year)





    HTH


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured