Date Time

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

    #1

    Date Time

    How do you get just the date part of a datetime value = 1/1/2005 11:15:00
    AM.

    Result = 1/1/2005

    Isn't there something built into the date functions in VB?

    I am using vb in asp.net

    Thanks


  • Alex

    #2
    Re: Date Time

    Craig,

    have a look at the DateTime.ToShor tDateString and DatePart methods.

    Alex
    http://www.DotNet42.com - The Answer to Your .NET Question


    "Craig" <NoSpam@hotmail .com> wrote in message news:ez5LY6A3FH A.320@TK2MSFTNG P10.phx.gbl...[color=blue]
    > How do you get just the date part of a datetime value = 1/1/2005 11:15:00
    > AM.
    >
    > Result = 1/1/2005
    >
    > Isn't there something built into the date functions in VB?
    >
    > I am using vb in asp.net
    >
    > Thanks
    >
    >[/color]

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Date Time

      "Craig" <NoSpam@hotmail .com> schrieb:[color=blue]
      > How do you get just the date part of a datetime value = 1/1/2005 11:15:00
      > AM.
      >
      > Result = 1/1/2005
      >
      > Isn't there something built into the date functions in VB?[/color]


      \\\
      Dim d1 As Date = ...
      Dim d2 As Date = d1.Date
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Date Time

        Craig,

        When you next time give a question about dates than don't do it with the
        sample you did.

        Because of the AM, I think that you are from the USA. If you use something
        as

        12/31/2005 11:15:00 AM than everybody can see that direct.

        The most easy method is to convert that string to a DateTime with
        Cdate(mystring) and than get the individual parts from a property or a
        method from that.

        http://msdn.microsoft.com/library/de...mberstopic.asp

        I hope this helps

        Cor


        Comment

        Working...