| 
 would any of the deDateTime Plugin help?  
(I thought all the leap year issues have been resolved there) 
  
  
Joseph Biran 
____________________________________________ 
 
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Herman 
Sent: Sunday, May 06, 2007 2:52 PM 
To: AmiBroker 
Subject: [amibroker] AFL Challenging: find yesterday's system data 
  
since there has been some talk about solving riddles using AFL one of you gurus might be in the mood to look at my problem:  
In my AT system I need to know the datenum for the previous trading day (Mon-Fri OK) using my system datetime as reference,  
i.e i should get that datenum even if I have no data for that day. 
  
TIA,herman. 
  
I got this far: 
  
// Leap year: 
//  1. Every Year divisible by 4 is a leap Year. 
//  2. But every Year divisible by 100 is NOT a leap Year 
//  3. Unless the Year is also divisible by 400, then it is still a leap Year. 
  
SysDateNum        = Now(3); 
SysYear         = int(SysDateNum/10000)+1900;                                  
LeapYear         = ( SysYear%4 == 0 AND SysYear%100 != 0 ) OR SysYear%400 == 0; 
SysMonth        = int(SysDateNum/100)%100; 
if( LeapYear ) DaysInMonth = "31,29,31,30,31,30,31,31,30,31,30,31"; 
else DaysInMonth = "31,28,31,30,31,30,31,31,30,31,30,31"; 
  
Title = "\n"+WriteIf(LeapYear,"LeapYear","NOT a LeapYear")+ 
", "+ NumToStr(SysYear,1.0,False)+"\n"+ 
"#Days in Month: "+DaysInMonth+"\n"+ 
"  Month Number: "+NumToStr(SysMonth,1.0,False); 
  
  
 |