I have complicated query over very big table.
Long story short, when I use convert time to select period of day (let’s say 12-13h, converting it from datetime row) query takes few minutes, instead of few seconds without convert!
So, I tried datepart, and it works well, almost instant, but, problem is, how to point to hours and minutes in same time?
Any other fast solution is more than welcome.
Thanks.
You can use datePart if you are willing to do a bit of math, as shown below:
15:40 = 15 * 60 + 40 = 940 minutes
select * …..
where datepart(mi, datefield) between (12*60+10) and (15*60+40)