[Lazarus] DateDif function needed

Michael Van Canneyt michael at freepascal.org
Sat Nov 9 12:12:29 CET 2013



On Fri, 8 Nov 2013, John Landmesser wrote:

> Hi List,
>
> i'm searching a pascal datetime function that simulates an Excel function: 
> "DateDif"
>
> Excel for example knows the function DateDif that returns the number of 
> Years, month and days between Date1 and date2.
>
> Date1 := 21.12.2012
> Date2 := 01.01.2013
>
> Result would be: 0 years, 0 moths, 11 days
>
> I tried to do it on my own, but without success.
>
> But i think there is a function out there but i don't know its name :-((

The dateutils unit contains DaysBetween, MinutesBetween, HoursBetween, etc. 
Each function exists in 2 variants: one which takes partial times, another which does complete days/hours/minutes.

See
http://www.freepascal.org/docs-html/rtl/dateutils/index-5.html

For the documentation.

Michael.




More information about the Lazarus mailing list