Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004

    Unanswered: Inserting only time

    I have a field in database which is defined of type date, i need it to hold only the time part with no date. Can the same be done. If so how ?

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    >Can the same be done.
    >If so how ?
    By not specifying the date portion of the format mask in TO_DATE.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 4
    DATE columns contain both date and time portions. You could do one of two things:

    a) store date and time and, when displaying the value, format it to show only time portion (just like Anacedent told you to)

    b) create field of a CHARACTER type and store time into it. Personally, I'd never (OK, in really, really rare ocasions) use CHARACTER datatype to do so. Trouble is waiting just around the corner - fetching data from such a column and applying an ORDER BY clause will cause you nothing but problems, as CHAR and DATE are not sorted the same way. Not to mention arithmetic operations etc. etc. My suggestion would be to use the a) approach.

  4. #4
    Join Date
    Jun 2004
    Liverpool, NY USA
    I Can't imagine why you would only want the time portion, however if you do store it in a date field use the SAME date, but different times, this will allow you to sort by the time. For example, something like.

    my_time = to_date('12314712'||TO_CHAR(SYSDATE,'hh24miss'),'MMDDYYYYHHMISS');
    Last edited by beilstwh; 10-17-05 at 10:54.
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts