Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004

    Exclamation Unanswered: inserting empty date


    I am using VB6 and SQL7. I am asking a user to enter a date if applicable - specifically a product manufactured date. I then take that date, using the dateadd function, query a table for a specific code, and calculate an expiration date based on the particular code.

    The problem - if the user does not enter a manufactured date, which is OK, SQL inserts 01/01/1900 - which I do not want. How do I handle?

    I am inserting the date, if there is one, from a flexgrid. I am declaring the variable as variant. The SQL field is DateTime.


    sSQL = "Insert into RecI(manufacdate) values ('" & (flxRec.TextMatrix(ctr,14)) & "')"

    Please Help!

  2. #2
    Join Date
    Nov 2002
    It's inserting the value 0 to the datetime column...

    Do you need to make the column nullable?

    Can you post the DDL of your table?

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jul 2003
    San Antonio, TX
    It should be done by passing parameters to a stored procedure that does an insert.

    But you can also do this (make sure manufacdate allows NULL):

    sSQL = "Insert into RecI(manufacdate) values (" & iif(flxRec.TextMatrix(ctr,14)="", "NULL", "'" & flxRec.TextMatrix(ctr,14) & "'") & ")"
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

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