[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Date difference [SOLVED]



PureBytes Links

Trading Reference Links

MC > From: Marek Chlopek [mailto:mchlopek@xxxxxxx]
MC > Sent: Wednesday, October 15, 2003 7:38 PM
MC > Subject: [amibroker] Date difference
MC > 
MC > Hello,
MC > 
MC > I have to calculate the difference in days between two dates. 
MC > Does anyone
MC > have a ready-to-use formula?


Hi,
this is the solution, i think.

==================================
function mcRATADIEDATE(yyyy, mm, dd)
// converts date to the Rata Die format
// yyyy - the year
// mm   - the month
// dd   - the day of the month
{
	yyyy = yyyy + int((mm-14)/12);
	mm = IIf(mm < 3, mm+12, mm);
	rd = dd 
	     + int((153*mm-457)/5) 
	     + 365*yyyy + int(yyyy/4) - int(yyyy/100) + int(yyyy/400) -306;
	return (rd);
};

Filter=1;

a = mcRATADIEDATE(1980, 01, 01);
b = mcRATADIEDATE(1981, 01, 01);

diff = b-a;

AddColumn(diff,"",1);

Buy = 0;
Sell = 0;

================================
Regards,
Marek Chlopek

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/