assign null value to datetime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vince

    #1

    assign null value to datetime

    I want to assign a null value to a DateTime variable.How
    do i do that?

    Thanks
    Vince
  • Jan Tielens

    #2
    Re: assign null value to datetime

    Since DateTime is a Value Type (not a Reference Type), so you can't assign
    null or Nothing to it. If you want to do something simelar, you could use
    the MinValue property:

    if(myDate == DateTime.MinVal ue)
    {
    //myDate is empty
    }

    Or you can use the Nullable Types library:
    open source, source code, freeware, shareware, programmer, developer, VB, Visual Basic, C++, C#, C Sharp, Oracle, Oracle8i, Oracle9i, VB 6, VB6, VB.NET, Visual Basic.NET, Visual Basic 6, Visual Studio, Visual Studio.NET, framework .net, dotNet, microsoft, oracle, OO, OOA, OOD, OOP, UML, unified modeling language


    Jan

    "vince" <anonymous@disc ussions.microso ft.com> wrote in message
    news:073f01c3ba 3a$88f51b20$a40 1280a@phx.gbl.. .[color=blue]
    > I want to assign a null value to a DateTime variable.How
    > do i do that?
    >
    > Thanks
    > Vince[/color]


    Comment

    • Ron McNulty

      #3
      Re: assign null value to datetime

      Sorry Vince, it is a value type, so it can't be null. I usually work around
      this by assigning DateTime.MinVal ue as the "null" value.

      Regards

      Ron

      "vince" <anonymous@disc ussions.microso ft.com> wrote in message
      news:073f01c3ba 3a$88f51b20$a40 1280a@phx.gbl.. .[color=blue]
      > I want to assign a null value to a DateTime variable.How
      > do i do that?
      >
      > Thanks
      > Vince[/color]


      Comment

      • Guest's Avatar

        #4
        assign null value to datetime

        You cannot assign null value to datetime because it's
        structure not a class. Stucture has to always has a value.

        Jan.
        [color=blue]
        >-----Original Message-----
        >I want to assign a null value to a DateTime variable.How
        >do i do that?
        >
        >Thanks
        >Vince
        >.
        >[/color]

        Comment

        Working...