Results 1 to 4 of 4

Thread: IsDate Problem

  1. #1
    falkon_tech is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Sep 2005
    Posts
    4
    Reputation
    0

    IsDate Problem

    I am building an import program that reads a text file and inserts it into a SQL table.

    One of the fields is a date. So I am doing an IsDate check on every record before it inserts. For some reason "0001-01-01" returns true on the isdate function but when it goes to the stored procedure to insert the record it errors.

    Is there any way around this? I know its just a data entry error on the users side, but I cannot fix it and would like to have the import just enter a null value since the date is invalid.

    Any thoughts?

    Thanks in advance!

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    12,995
    Reputation
    1627
    Does your database have a minimum value that it recognises as a valid date? That's the only reason i can see that would cause that error. If so then you'd need to hard-code a check against that date before entering the value into the database.

  3. #3
    falkon_tech is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Sep 2005
    Posts
    4
    Reputation
    0
    i ended up just putting a check to see if the date value is less than the minimum value.

    my question though, is why does the IsDate function return a True value, but SQL does not?

  4. #4
    TechGnome is offline VB.NET Forum Idol
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    May 2005
    Posts
    896
    Reputation
    233
    Because there's something builtin to SQL that says a date cannot be less than a specific value. Doesn't mean it's an invalid date... just there would be no way to accurately store it in the DB.

    -tg
    Please don't PM me with your problems, I am not a therapist. Private help isn't condusive to the general knowledge of the community, so keep it out in the open.
    * Create Disconnected ADO Recordset Clones * Intro ADO 101 * Intro to ADO 102 * Intro to ADO.NET, part 1 * Intro to ADO.NET, part 2 * Set your VB6 ActiveX Compatibility

Bookmarks

Posting Permissions

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