There should be no dashes and date or times, you also need to use two equal signs to test for equality:
bi1=ValueWhen(DateNum() == 1070101, bi); bi2=ValueWhen(DateNum() == 1071201, bi); As per the documentation: "10000 * (year - 1900) + 100 * month + day, so 2001-12-31 becomes 1011231 and 1995-12-31 becomes 951231 " -hi --- In amibroker@yahoogroups.com, "mahesh" <inquisitive2...@...> wrote: > > dear membersI tried the following code in commentary(to find bars between 2 > dates) as suggested by TJ. > bi=BarIndex(); > bi1=ValueWhen(DateNum()=2007-1-1,bi); > bi2=ValueWhen(DateNum()=2007-12-1,bi); > ãnumbars=LastValue(bi1-bi2); > WriteVal(numbars); > (1)but i got the following error- > > Error in AFL formula: > bi2=ValueWhen(DateNum()=2007-12-1,bi); > numbars=LastValue(bi1-bi2)-------------------------^ > Error 29.Variable 'bi2' used without having been initialized.(2)plz in what > format DateNum accepts the date? whether in quotes?regards mahesh > >