[Lazarus] DateDif function needed

waldo kitty wkitty42 at windstream.net
Thu Nov 14 20:48:51 CET 2013


On 11/14/2013 12:26 PM, Bart wrote:
> On 11/14/13, waldo kitty <wkitty42 at windstream.net> wrote:
>
>> you are completely right, IMHO... one simply needs to choose their desired
>> base and level of error that is acceptable for their task's needs...
>
> It's all about definition.

right... that's what i meant by "desired base"... eg: calendar, SI notation, 
Julian, Gregorian, etc...)

> For me I would think that given "today" is the last day of a given
> month, then "today" + 1 month = the same date on in the next month,

agreed...

> or if the next month has fewer day, the last day of the next month.

yeah... i'm undecided on that :? (** below) my current code returns the following...

2012-01-29 to 2012-02-29 is 0 yrs 1 mos 0 days
2012-01-29 to 2012-03-01 is 0 yrs 1 mos 3 days
2012-01-29 to 2012-03-31 is 0 yrs 2 mos 2 days
2012-01-29 to 2012-04-30 is 0 yrs 3 mos 1 days
2012-01-29 to 2012-05-31 is 0 yrs 4 mos 2 days
2012-01-29 to 2012-06-30 is 0 yrs 5 mos 1 days
2012-01-29 to 2012-07-31 is 0 yrs 6 mos 2 days
2012-01-29 to 2012-08-31 is 0 yrs 7 mos 2 days
2012-01-29 to 2012-09-30 is 0 yrs 8 mos 1 days
2012-01-29 to 2012-10-31 is 0 yrs 9 mos 2 days
2012-01-29 to 2012-11-30 is 0 yrs 10 mos 1 days
2012-01-29 to 2012-12-31 is 0 yrs 11 mos 2 days

2012-01-31 to 2012-02-29 is 0 yrs 0 mos 29 days**
2012-01-31 to 2012-03-01 is 0 yrs 1 mos 1 days
2012-01-31 to 2012-03-31 is 0 yrs 2 mos 0 days
2012-01-31 to 2012-04-30 is 0 yrs 2 mos 30 days**
2012-01-31 to 2012-05-31 is 0 yrs 4 mos 0 days
2012-01-31 to 2012-06-30 is 0 yrs 4 mos 30 days**
2012-01-31 to 2012-07-31 is 0 yrs 6 mos 0 days
2012-01-31 to 2012-08-31 is 0 yrs 7 mos 0 days
2012-01-31 to 2012-09-30 is 0 yrs 7 mos 30 days**
2012-01-31 to 2012-10-31 is 0 yrs 9 mos 0 days
2012-01-31 to 2012-11-30 is 0 yrs 9 mos 30 days**
2012-01-31 to 2012-12-31 is 0 yrs 11 mos 0 days

> So
> - april 30th + 1 month = may 30th
> - march 31st + 1 month = may 30th (not june 1st)
> Yet all of our "tools" (includimg mine) say march 31st to april 30th =
> 0 months + 30 days...

i know what you mean ;) :)

-- 
NOTE: No off-list assistance is given without prior approval.
       Please keep mailing list traffic on the list unless
       private contact is specifically requested and granted.




More information about the Lazarus mailing list