Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Days between function 3

Status
Not open for further replies.

sggaunt

Programmer
Jul 4, 2001
8,620
0
0
GB
I am correct in thinking that the DaysBetween() function takes no account of leap years?
I had a look at the sources and it gets the difference between the two dates in milliseconds using DateTimetoMilliseconds() on the Start and end dates.
DateTimeToMilliseconds uses DateTimeToTimeStamp which is written in assembler, I really don't know if the data part of the array that is filled here is taking account of leap years.

My results seem to suggest that it isnt, but it might just be a difference error on my part i.e I am displaying the difference between the two dates and not the taking account of the current (start) and end dates.



Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast
 
Not sure I understand correctly, but try to do a test with the code below:

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage( '2012/02/28 - 2012/03/01 = ' +
               IntToStr( DaysBetween(EncodeDate(2012, 2, 28),
                                     EncodeDate(2012, 3, 1)) ) +
               sLineBreak +
               '2013/02/28 - 2013/03/01 = ' +
               IntToStr( DaysBetween(EncodeDate(2013, 2, 28),
                                     EncodeDate(2013, 3, 1)) ) );
end;

Hope it's useful.


[URL unfurl="true"]http://www.imoveisemexposicao.com.br/imobiliarias-em-guarulhos[/url]
 
cheers imex, seems it does know about Feb 29th !
also I had not come across the CR/LF constant before, nice one.



Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top