Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I determine how many months, weeks and days have elapsed between two dates?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. CODetermining weeks and days between the dates is basically trivial - there is a fully deterministic formula for doing that. As soon as you mention 'months' too, you wander off the straight-and-narrow path into the tangled undergrowth. You have to define (rigorously) what a month means, in all circumstances, remembering to account for leap days. Where it gets interesting is with combinations like 2010-02-28 and 2010-05-29, or 2012-02-29 and 2012-05-28 (29, 30, 21), etc. Since 'a month' is a variable quantity, we have to know what meaning you want to ascribe to 'month' to know what value to give.
      singulars
    2. COFWIW: Oracle's MONTHS_BETWEEN() function gives interesting results for the pairs of dates cited - the values are: 3.03225806451613, 2.96774193548387, 3.0, 3.03225806451613, 3.0 respectively. Note that the number of months between 30th May and 29th February is bigger than the number of months between 31st May and 29th February. That is the definition of MONTHS_BETWEEN(). You have to know about this to use it. Of course, Oracle's MONTHS_BETWEEN is not implemented in SE, only in IDS. But the point stands - without the requisite definition of MONTH, no-one can produce the code for you.
      singulars
    3. CO@Jonathan- OK, do you remember the dates dimension lookup table my app uses (see posting: "Date lookup table 1990-01-01:2041-12-31")?.. Can you think of a method in which I could devise an algorithim which would accomplish my goal?.. or should I just use 30.5 days avg., rounding all months to 31 days to base YMWD calcs?.. it would be to all customers advantage that every month is based on 31 days, when some months actually have 28, 29 and 30 days because customers will get these days for free when calcking their interest amt's, (e.g. 16 to 31 days = 20% interest, 32 to 36 days = 25%..) ;-)
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload