Solved

# Julian Dates

Posted on 1999-01-06

Can someone please help.

I'm running a program where i'm converting dates to julian days.

When I run the formula in D3 i get the correct answer for today 199/01/06. When I rin it in D4 I get the wrong answer with the exact same formula. Why?

The prog is as follows:= D4 answer=805073198 D3 answer=2451185.

function date2julian(date:tdatetime):integer;

var y,m,d:word;

jd:integer;

begin

decodeDate(date,y,m,d);

jd:= ( 1461 * ( y + 4800 + ( m - 14 ) div 12 ) ) div 4 +

( 367 * ( m - 2 - 12 * ( ( m - 14 ) div 12 ) ) ) div 12 -

( 3 * ( ( y + 4900 + ( m - 14 ) div 12 ) div 100 ) ) div 4 +

d - 32075;

date2julian:=jd;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

edit1.text:=inttostr(date2julian(now));

end;