Bar number from DateTime

Hello,

Can someone eplain how to get the bar index from a timestamp / date, especially on a tick chart.
Thanks