MyChat Scripts Engine: YearsBetween
Function to calculate how many whole years between two specified dates.
Syntax
function YearsBetween(dNow, dThen: double): integer;
Parameters and return values
Prameter |
Type |
Value |
dNow |
double |
initial date/time value; |
dThen |
double |
date/time value with which we compare the dtNow date value. |
Function result
Number of whole years between two selected dates. If the first date value is less than the second one then the number will be positive, if greater negative.
Example
var
dtFrom, dtNow: double;
begin
// MyChat version 3.0 release date
dtFrom := EncodeDateTime(2007, 7, 2, 13, 0, 0, 0);
// and now
dtNow := Now;
// print this dates
mLogScript('From date: ' + FormatDateTime('mm.dd.yyyy hh:nn:ss', dtFrom), '');
mLogScript('To date: ' + FormatDateTime('mm.dd.yyyy hh:nn:ss', dtNow), '');
mLogScript('Years from MyChat 3.0 birthday: ' + IntToStr(YearsBetween(dtFrom, dtNow)), '');
end.
Script work result
[10:34:32] (Log "YearsBetween"): From date: 02.07.2007 13:00:00
[10:34:32] (Log "YearsBetween"): To date: 04.07.2016 10:34:32
[10:34:32] (Log "YearsBetween"): Years from MyChat 3.0 birthday: 9