Getting Time From Date Stamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ren07
    New Member
    • Sep 2007
    • 2

    Getting Time From Date Stamp

    haii i need to get the time from the date time stamp which is stored in the database(SQL).. ............

    i am getting the date time stamp like this..01-Jan-2000 08:00:00

    i want it like..08:00:00. .

    can anyone help me please...
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by ren07
    haii i need to get the time from the date time stamp which is stored in the database(SQL).. ............

    i am getting the date time stamp like this..01-Jan-2000 08:00:00

    i want it like..08:00:00. .

    can anyone help me please...
    Please check out the Date class for a list of all of the methods that can be used to retrieve the Time value from a Date object. You will be most interested in the Hour, Minute, Second properties of the date class.

    If your time stamp is not in the format of a date, you are going to have to research how to parse Strings to retrieve the value that you are looking for.

    -Frinny

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Ahem, frinny i think too quickly copy/pasted her link.
      You're looking for the DateTime object.
      Particularily if you have that string from the database you could do:
      DateTime myDT=DateTime.P arse(mystring);

      And then myDT would be an instance of the DateTime object equal to the value from the database. You can use the properties of the DateTime object to get just the time values.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by Plater
        Ahem, frinny i think too quickly copy/pasted her link.
        >>blush<<
        Originally posted by Plater
        You're looking for the DateTime object.
        Plater's right....don't know why I went for the Date object anyways, I haven't used it in a long time.

        Comment

        Working...