tsql - SQL: match time on several minutes -


i'm trying match datetimes 2 different tables. table has regular time (09:29:35). table b has rounded time (09:30).

the time table b match time table a, or match minute before due rounding.

how can match these times? or, how can 'remove' seconds table , round minutes on table well?

thanks in advance!

you can remove seconds cast:

convert(varchar(16), getdate(), 120) 

this chops date after seconds, f.e. 2011-06-30 19:50 (16 characters long.) adding or substracting minutes can done dateadd.

if combine in join, like:

select  *    tablea join    tableb on      convert(varchar(16), tablea.datecolumn, 120) between         convert(varchar(16), dateadd(m,-1,tableb.datecolumn), 120)         , convert(varchar(16), dateadd(m,1,tableb.datecolumn), 120) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -