Results 1 to 3 of 3

Thread: DateTime datatype

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    DateTime datatype

    How to insert a null value in a column of datatype 'DateTime'? I am coding in c#.

    Thanks,
    Thanks.

  2. #2
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: DateTime datatype

    i dont think you can
    is column required????

    d2005 - pure novice

  3. #3
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: DateTime datatype

    The DateTime object is essentially a struct, thus it's stored on the stack (where as classes are stored on the heap). Therefore, it cannot be null.

    However, this has been provided for - there are static properties that one may use: "MinValue" and "MaxValue". If you initialise the instance to (for example) DateTime.MinValue, you can perform a check against that.

    Code:
    DateTime myDate = DateTime.MinValue;
    if (myDate == DateTime.MinValue) {
        // Your code that would be executed if the instance is not initialised.
    }

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