Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2008
    Posts
    99

    Unanswered: trunc(to_timestamp())

    Hello
    Here it says trunc accepts date formats,does this mean it accepts timestamp data type?
    Oracle/PLSQL: Trunc Function (with dates)

    send_date in timestamp(6) format.
    trunc(send_date)=trunc(timestamp('01-01-2009','dd-mm-yyyy))

    Kind Regards

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    What prevented you to try?
    Code:
    SQL> select systimestamp, trunc(systimestamp) truncated from dual;
    
    SYSTIMESTAMP                                                 TRUNCATED
    ------------------------------------------------------------ ----------------
    08.07.09 17:15:38.765000 +02:00                              08.07.2009 00:00
    
    SQL>

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You should NOT rely on implicit type conversion during data presentation; ALWAYS use TO_CHAR()!
    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.

  4. #4
    Join Date
    Dec 2008
    Posts
    99
    Quote Originally Posted by Littlefoot
    What prevented you to try?
    Code:
    SQL> select systimestamp, trunc(systimestamp) truncated from dual;
    
    SYSTIMESTAMP                                                 TRUNCATED
    ------------------------------------------------------------ ----------------
    08.07.09 17:15:38.765000 +02:00                              08.07.2009 00:00
    
    SQL>
    I failed to run this.Do I have to use "trunc" here,even though send_date is in timestamp(6) format.

    trunc(send_date)=to_timestamp('01-01-2009','dd-mm-yyyy))

    Best Regards

  5. #5
    Join Date
    Dec 2008
    Posts
    99
    Quote Originally Posted by anacedent
    You should NOT rely on implicit type conversion during data presentation; ALWAYS use TO_CHAR()!
    I think you are suggesting to use this one
    to_char(send_date,'dd-mm-yyyy')='01-01-2009'


    can you explain why I should not use "to_timestamp" conversion,what is the risk?

    And if you run this,you ll get wrong output.
    to_char(send_date,'dd-mm-yyyy')>='07-07-2009'


    Best Regards
    Last edited by sunsail; 07-09-09 at 09:19.

Posting Permissions

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