how can i get time only in date data type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gozdeata
    New Member
    • Oct 2008
    • 5

    how can i get time only in date data type

    hey there,
    i m trying to get only time information of a date type variable.
    i got a column in type of char, it keeps time info in hh:mm format - 5 characters
    when i tried to convert it to date with to_date([variable], 'hh24:mi') it gives me a date starts with the ifrst day of current mount, year etc.
    01/10/2008 14:04 for example.

    i need a solution to get time info in date data type from a char column in hh:mm

    thanx for ypur care...
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Your requimrent is not clear.Are you trying to convert the char data in to time format or are you trying to extract a time from a current date?

    Comment

    • gozdeata
      New Member
      • Oct 2008
      • 5

      #3
      i m trying to convert char data (for example 15:30) into date data type.
      to_date('15:30' ,'hh24:mi') function gives it to me with a date that belong to first day of the current mount. for example as 01/10/2008 15:30 i f we cosider today. i need only time info.
      thanks for your care...
      Gözde

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        You can store both date a dnd time in a date value .Which can later be extracted as desired for any processing or rerporting purpose.

        Comment

        • amitpatel66
          Recognized Expert Top Contributor
          • Mar 2007
          • 2358

          #5
          Originally posted by gozdeata
          i m trying to convert char data (for example 15:30) into date data type.
          to_date('15:30' ,'hh24:mi') function gives it to me with a date that belong to first day of the current mount. for example as 01/10/2008 15:30 i f we cosider today. i need only time info.
          thanks for your care...
          Gözde

          Use TO_CHAR(column_ name,'HH24:MI') or TO_CHAR(TO_DATE ('15:30','HH24: MI'),'HH24:MI')

          Comment

          • gozdeata
            New Member
            • Oct 2008
            • 5

            #6
            Originally posted by amitpatel66
            Use TO_CHAR(column_ name,'HH24:MI') or TO_CHAR(TO_DATE ('15:30','HH24: MI'),'HH24:MI')
            sorry that i think i couldn't explain my problem clearly
            above fınctions gives it to me as character. i need time info in date type. when i use to_date() with 'hh24:mi' it gives me with an unwanted date info. i need only time...

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              try to use EXTRACT function.

              Comment

              Working...