Forum Stats

  • 3,826,113 Users
  • 2,260,598 Discussions
  • 7,896,790 Comments

Discussions

"CEIL"-function for dates

Carsten Kaftan
Carsten Kaftan Member Posts: 10 Bronze Badge
edited May 7, 2020 7:25PM in Database Ideas - Ideas

A minor nuisance is to determine the closing border of an arbitrary interval covering a date-time-value.

It would be nice to have CEIL(SYSDATE, 'MM'), CEIL(SYSDATE, 'YYYY'), etc. analogous to TRUNC(SYSDATE, 'MM'), TRUNC(SYSDATE, 'YYYY'), etc. It´s possible for instance, to use the calendaring syntax for this purpose, but it would be neater for configuration-entries, for selection of date-intervals, etc. to be able to use an equivalent of TRUNC.

(This is the renewal of the enhancement request 6331253.992, accepted — "Please monitor it from time to time keeping in mind that it may take some long time to be applied." — from Oracle on 31-May-2007.)

Carsten KaftanUser259623 -Oracletop.gunChandrakaanth RamamurthyMike Kutzvinaykumar2pankajrangaManish ChaturvedimarkmevansJohn GunterctriebulohmannArpit Jain -OracleHari Meena-OraclePravin TakpirecaadecarvalhoRajenBTSharma-OracleLothar Flatzfac586JagadekarabhagatsinghChris HuntMartin PreissWilliam RobertsonsysassysdbaGeert GruwezSven W.ApexBineBPeaslandDBAsensoftAparna Dutta-OracleBrunoVromanKayKJeffrey KempJustin WarwickLukas EderNiels HeckerJohn_KMichaelRThorsten KettnerUser_WGPZXsdstuber
43 votes

Under Review - Voting Still Open · Last Updated

Comments

  • William Robertson
    William Robertson Member Posts: 9,567 Bronze Crown
    edited Jun 3, 2016 5:46AM

    This would work well with my proposed idea:

    <strong>  where</strong> event_date <strong>between</strong> start_date <strong>and ceil(</strong>start_date<strong>,'</strong>DD<strong>') <span style="color: red;">exclusive</span></strong>

  • Chris Hunt
    Chris Hunt Member Posts: 2,066 Gold Trophy
    edited Aug 11, 2015 9:11AM

    This would work well with my proposed idea:

    <strong>  where</strong> event_date <strong>between</strong> start_date <strong>and ceil(</strong>start_date<strong>,'</strong>DD<strong>') <span style="color: red;">exclusive</span></strong>

    That depends upon what exactly the proposed CEIL() function actually returns. Personally I'd find it more useful if it returned the last second of the time period concerned, rather than the first second that falls outside it.

    i.e. CEIL(sysdate,'yyyy') should return 23:59:59 on 31 December this year, rather than 00:00:00 on 1st January next year.

    Sven W.ApexBinervstucke
  • rvstucke
    rvstucke Member Posts: 11

    That depends upon what exactly the proposed CEIL() function actually returns. Personally I'd find it more useful if it returned the last second of the time period concerned, rather than the first second that falls outside it.

    i.e. CEIL(sysdate,'yyyy') should return 23:59:59 on 31 December this year, rather than 00:00:00 on 1st January next year.

    Chris, I totally agree.  I'm always doing a   between   from_date   and   trunc(end_date)+86399/86400  just to get the last second included in a date range.

  • John_K
    John_K Member Posts: 2,498 Gold Trophy

    I hadn't seen this idea when I posted a very similar one unfortunately:

    My idea was to use the functions on not just dates, but intervals too.