1. Tech

Your suggestion is on its way!

An email with a link to:

http://delphi.about.com/library/rtl/blrtlDaysBetween.htm

was emailed to:

Thanks for sharing About.com with others!

Glossary|Tips/Tricks|FREE App/VCL|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit

DaysBetween

unit
DateUtils
category
date/time routines
declaration
function DaysBetween(const ANow, AThen: TDateTime): Integer;
description
Gives the number of whole days between two specified dates.

Function counts only whole days. What this means is that it will return 0 as the result for difference between 05/01/2003 23:59:59 and 05/01/2003 23:59:58 - where the actual difference is one *whole* day minus 1 second.

example
var dtNow, dtBirth : TDateTime;
    DaysFromBirth : integer;

dtNow := Now;
dtBirth := EncodeDate(1973, 1, 29);
DaysFromBirth := DaysBetween(dtNow, dtBirth);

ShowMessage('Zarko Gajic "exists" ' + 
            IntToStr(DaysFromBirth) + ' whole days!'); 

in real code
see also
EncodeDate, IncMonth, Now, DaySpan, WithinPastDays


Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

Got some code to share? Got a question? Need some help?

©2014 About.com. All rights reserved.