a = 1;
b = -1;
yi = Pi/6;
xmax = 20.;
ydi = 0;
SGEqBterm = {Y''[x] == a Sin[Y[x]] Cos[Y[x]] + b Cos[Y[x]],
Y'[0] == ydi, Y[0] == yi};
sol = First@
NDSolve[{SGEqBterm,
WhenEvent[Y[x] == yi, period = x; "RemoveEvent",
"DetectionMethod" -> "DerivativeSign"]}, Y, {x, -2 xmax, 2 xmax}]
sol = First@
NDSolve[{SGEqBterm,
WhenEvent[Y[x] == yi, period = x; "RemoveEvent",
"DetectionMethod" -> "DerivativeSign",
"IntegrateEvent" -> True]}, Y, {x, -2 xmax, 2 xmax}]