none
How to set a date type variable to null, nothing or such RRS feed

  • Question

  • I created an User Defined Type that holds a Deadline property which is date type. Whenever there is no Deadline set yet, I would like such property to be set to Null, Nothing or such. I noticed that if I just Dim a Date Type variable its value will be already set to 12:00 AM, and the same value takes place if I set the variable to a blank cell value. Any ideas to get around of this problem?

    Jorge Barbi Martins (jorge.barbi@hotmail.com)

    Tuesday, February 10, 2015 2:05 AM

Answers

  • A variable of type Date cannot be empty. Its default value is 0, which corresponds to Midnight on 30 December 1899.

    If you want to be able to make it empty, declare it as Variant instead of as Date. You can then set its value to Null.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, February 10, 2015 6:43 AM

All replies

  • A variable of type Date cannot be empty. Its default value is 0, which corresponds to Midnight on 30 December 1899.

    If you want to be able to make it empty, declare it as Variant instead of as Date. You can then set its value to Null.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, February 10, 2015 6:43 AM
  • That's right Hans. Thanks once again.

    Jorge Barbi Martins (jorge.barbi@hotmail.com)

    Tuesday, February 10, 2015 11:41 PM