how to get milliseconds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ndedhia1
    New Member
    • Jan 2009
    • 112

    how to get milliseconds

    I want hr:min:sec:mill isecs.
    Can someone please tell me DATETIME is the correct type and what should go inside the parantheses.

    If i am doing a:
    CREATE TABLE startTable
    (TIMESTAMP DATETIME()

    thanks
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Firstly, you cannot use the column name as timestamp because its an oracle keyword.

    In detail about timestamp, Check here

    Comment

    • ndedhia1
      New Member
      • Jan 2009
      • 112

      #3
      I will change the column name to something else but I still was not able to figure out the code that gave me hour, min, sec and milliseconds.

      thanks

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Try this:

        [code=oracle]

        SQL> ed
        Wrote file afiedt.buf

        1 select
        2 to_char(systime stamp,'dd-mm-yyyy hh24:mi:ss.FF') as ts,
        3 to_timestamp(
        4 to_char(sysdate ,'dd-mm-yyyy hh24:mi:ss.')
        5 ||
        6 to_char(
        7 to_number(
        8 to_char(systime stamp,'FF')
        9 ) + 250),'dd-mm-yyyy hh24:mi:ss.FF'
        10 ) as ts_milliseconds
        11* from dual
        SQL> /

        TS TS_MILLISECONDS
        ----------------------------- ----------------------------------------------------------------------
        26-02-2009 06:51:09.072583 26-FEB-09 06.51.09.728330 000 AM

        SQL>

        [/code]

        Comment

        • madankarmukta
          Contributor
          • Apr 2008
          • 308

          #5
          Originally posted by ndedhia1
          I want hr:min:sec:mill isecs.
          Can someone please tell me DATETIME is the correct type and what should go inside the parantheses.

          If i am doing a:
          CREATE TABLE startTable
          (TIMESTAMP DATETIME()

          thanks

          Hi,

          I would suggest you to specify the format in which you want to display the data from the table column while creating the table itself.

          Thanks!

          Comment

          • ndedhia1
            New Member
            • Jan 2009
            • 112

            #6
            I want the display to be:
            hour:minute:sec ond:millisecond s

            so is this the write syntax?
            CREATE TABLE startTable(
            ERROR_TIME DATETIME('HH:MM :SS:nnn'));

            thanks

            Comment

            • amitpatel66
              Recognized Expert Top Contributor
              • Mar 2007
              • 2358

              #7
              You dont have anything called datetime() in oracle. I think it is in MS SQL server. if you are working with MS SQL then you thread needs to be moved to that forum. Please confirm which database you are using?

              If you are using oracle, then getting Millisecond as I suggested in my previous post.You can use that query.

              Comment

              • ndedhia1
                New Member
                • Jan 2009
                • 112

                #8
                sorry..i have moved the thread over to mysql

                thanks

                Comment

                • amitpatel66
                  Recognized Expert Top Contributor
                  • Mar 2007
                  • 2358

                  #9
                  Thread moved from oracle forum to mysql forum since the question is related to MYSQL DB

                  Moderator

                  Comment

                  Working...