How to subtract minutes from datetime field in SQL -


trying figure how subtract minutes datetime field.

select     '1' ppcono, b.new_salesrepid pprep1,     max(a.actualend - c.timezonebias) ppdate,     count(b.new_salesrepid) ppcount      activitypointerbase join     systemuserextensionbase b on b.systemuserid = a.ownerid join     usersettingsbase c on c.systemuserid = b.systemuserid     b.new_salesrepid <> '99999999'     , a.activitytypecode = '4201'     , b.new_salesrepid not null     , a.statecode = '1'     , convert(varchar(8), a.actualend, 112) = '20140627' group     b.new_salesrepid, convert(varchar(8), a.actualend, 112) order     b.new_salesrepid asc; 

from code above, part max(a.actualend - c.timezonebias) a.actualend datetime field being pulled in , c.timezonebias value in minutes trying subtract. every time run it, subtracts days , not minutes. in case c.timezonebias actual value '300' it's subtracting 300 days , not 300 minutes.

i find easiest way use arithmetic:

max(a.actualend - c.timezonebias / cast(24 * 60 float)) ppdate 

this converts timezonebias fractions of day.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -