# How to find the number of bars in a given day

Hi,
I am exploring AFL. i need to find number of bars exist in a particular day. I got the logic to write but my syntax is wrong. Is there any correct approach to find the number of bars in a particular day?

``````Count=0;
for (i=0;i<BarCount;i++)
{

if (Day()== DateTime(today))
{
Count = Count+1;

}

}

printf(Count);

``````

Do not use array functions within barcount loop.
First read understanding how AFL works.

Few days ago:

So changing just very few things

``````/// @link https://forum.amibroker.com/t/how-to-find-the-number-of-bars-in-a-given-day/11057/2
/// similar to
my_date = "2019-01-16";
//
bi = BarIndex();
dn = DateNum();
newday = dn != Ref( dn, -1);
//
StartBI = ValueWhen(newday, bi, 2);
EndBI = ValueWhen(newday, bi, 1);
bars_yesterday = EndBI-StartBI;

Condition = Ref(dn,-1) == DateTimeConvert(0, _DT(my_date)) AND newday;

printf( "#Bars of date: %g", ValueWhen(condition, bars_yesterday));

Filter = Condition;
Addcolumn(bars_yesterday, "#Bars of date " + my_date, 1 );

Plot( C, "Price", colorDefault, styleCandle );
``````

And if you want to get bars of today then it is just

``````dt = DateTime();
dn = DateNum();
newday = dn != Ref( dn, -1);

Filter = Status("lastbarinrange");
// or use
//Filter = Status("lastbarinrange")  OR newday; // for every day bar number

SetOption( "NoDefaultColumns", True);