DateDiff Funtion
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: DateDiff Funtion

  1. #1
    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    323
    Hi

    Is there any readily available DateDiff function in Oracle, which is available in SQL server? My main intension is when I pass the parameters as
    DateDiff(ss, current_timestamp,lastacc_datetime), it should return the value in no of seconds, same as for mi and hh.

    If any one already has this kind of function, Can you please share with this forum? Or can you suggest me the logic in PL/SQL.

    Regards


    Nagesh

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    Hi,
    there is no special function for that.
    If you simply subtract two dates you get the difference in days. You can get hours, mins and secs with multiplicaton by 24, 24*60, 24*60*60.
    Ales

  3. #3
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,095
    For example:
    Code:
    SQL> select sysdate - to_date('04/06/2002','mm/dd/yyyy') from dual;
    
    SYSDATE-TO_DATE('04/06/2002','MM/DD/YYYY')
    ------------------------------------------
                                    4.47871528
    
    SQL>  select (sysdate - to_date('04/06/2002','mm/dd/yyyy')) * 24*60 secs from dual;
    
          SECS
    ----------
       6450.75
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  4. #4
    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    323
    This is why I love this forum. Thanks to all for your contribution.


    Regards
    Nagesh

Posting Permissions

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



Click Here to Expand Forum to Full Width