Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    3

    Unanswered: inserting null value to date field

    Is there any way of setting NULL to nullable date field other than the following two.
    1.Hard coding as NULL
    2.Leaving the field name in the field list while inserting

    I am looking for something like converting from a string etc....


    Can anyone help me?????????????????????/

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    If you are inserting the row there are two ways:

    INSERT into my table (Col1,col2,ColDate) values (1,2,NULL)
    INSERT into mytable (col1,col2) values (1,2)

    First one explicitly sets it to null while the second implicitly sets it to null (if no default value has been specified for the date column).

    For updating, you must explicitly set it to NULL.

    HTH

    Andy

  3. #3
    Join Date
    Apr 2003
    Posts
    191
    Hi,

    NULLIF *may* be your friend:

    INSERT into my table( ..., coldate) values (..., NULLIF('0', YOURCOLUMN) )

    should insert a NULL if YOURCOLUMN happens to be '0'.

    Johann

    Originally posted by ARWinner
    If you are inserting the row there are two ways:

    INSERT into my table (Col1,col2,ColDate) values (1,2,NULL)
    INSERT into mytable (col1,col2) values (1,2)

    First one explicitly sets it to null while the second implicitly sets it to null (if no default value has been specified for the date column).

    For updating, you must explicitly set it to NULL.

    HTH

    Andy

Posting Permissions

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