Results 1 to 5 of 5
  1. #1
    Join Date
    May 2008
    Posts
    2

    Unanswered: calculate days or hours

    Hi
    i have a question about calculating of days or hours in oracle.
    How can i calculate the number of days in february 1900 or hours between 1.3.2008 - 1-4-2008 ?

    thx

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >How can i calculate the number of days in february 1900 or hours between 1.3.2008 - 1-4-2008 ?
    By using basic arithmetic.

    what does this question have to do with Oracle?
    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
    May 2008
    Posts
    2
    i have to find out the number of days in feb 2000 with help of Oracle DUAL . So i need a PL/SQL query to find out. Which function can i use for it?

    thx

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    Last edited by anacedent; 05-24-08 at 11:52.
    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.

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    i have to find out the number of days in feb 2000 with help of Oracle DUAL.
    OK
    So i need a PL/SQL query to find out.
    Wrong! You don't need PL/SQL to do that; a simple SELECT statement should be enough. Why do you think you need PL/SQL, anyway?

    In Oracle, when subtracting two dates, you get number of days. For example:
    Code:
    SQL> select to_date('25.05.2008', 'dd.mm.yyyy')
      2       - to_date('13.05.2008', 'dd.mm.yyyy') days
      3  from dual;
    
          DAYS
    ----------
            12
    
    SQL>
    Number of hours would be "number of days * 24", right?

    Oracle offers several functions that deal with dates; as you didn't mention your database version, here's a link to 10g datetime functions. Study their use and you should be able to find the result.

Posting Permissions

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