It should give you '00:00:00'
Lets split it into smaller parts:
this is the original expression:
<pre>set @BeginTime = DateAdd(mi,-Datepart(mi,@BeginTime)-Datepart(hh,@BeginTime)*60,@BeginTime ) </pre>
Now, let's suppose we make
<pre>A = Datepart(mi,@BeginTime)</pre>
and
<pre>B = Datepart(hh,@BeginTime)</pre>
So, our main expression is now:
<pre>set @BeginTime = DateAdd(mi,-A-B*60,@BeginTime )</pre>
which, is the equivalent to:
<pre>set @BeginTime = DateAdd(mi,-A-<b>(</b>B*60<b>)</b>,@BeginTime )</pre>
Now, let's calculate A and B.
<pre>A = Datepart(mi,'16:45:00') = 45
B = Datepart(hh,'16:45:00') = 16</pre>
So, we have
<pre>set @BeginTime = DateAdd(mi,-45-(16*60),'16:45:00' ) = DateAdd(mi,-1005,'16:45:00' )</pre>
And 1005 minutes are equal to 16 hours and 45 minutes, so the result is 0 minutes (i.e. '00:00:00').
Thanks!!
You are welcome.
Summarizing, that expression will substract the hours and minutes from the original time, and the result will be just the seconds, which in this case were 0.