sql server - SQL Filter Out Specific Month, Day, and Time for Any Year -


microsoft dynamics nav uses datetime of yyyy-12-31 23:59:59.000 identify yearly closing entries. trying write report bring of entries, except these. query works fine 2014 if explicitly use where clause of

where [posting date] <> '2014-12-31 23:59:59.000') 

but need query work year. tried:

where (datepart(mm, [posting date]) <> 12) ,        (datepart(dd, [posting date]) <> 31) ,        (datepart(hh, [posting date]) <> 23) ,        (datepart(mi, [posting date]) <> 59) ,        (datepart(ss, [posting date]) <> 59) 

but filtered out in december or had day of 31 or hour of 23, etc...

is there simple way filter given datetime, year?

may this:

where month([posting date]) <> 12 or       day([posting date]) <> 31 or       cast([posting date] time) <> cast('23:59:59.000' time) 

even more short answer:

where year([posting date]) <> year(dateadd(ss, 1, [posting date])) 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -