sql server - sql query to get records between dates -
id | status | value | createddatetime -----+--------+--------+------------------------ 1 | open | y | 2014-12-10 14:03:10.100 2 | open | y | 2014-12-10 13:03:10.100 3 | open | n | 2014-12-10 13:01:12.100 4 | open | y | 2014-12-10 05:02:11.100 5 | open | n | 2014-12-09 15:03:10.100 6 | open | n | 2014-12-08 14:03:10.100 7 | open | y | 2014-12-08 14:03:10.100
i wants write sql query records 2014-12-08 14:03:10.100
2014-12-10 14:03:10.100
, status
should open
value = y
.
i tried below sql query-
select * mytable createddatetime between '2014-12-08 14:03:10.100' , '2014-12-10 14:03:10.100' , status in ('open') , value='y'
how this
select id,status,value,createddatetime <table> createddatetime between '2014-12-08 14:03:10.100' , '2014-12-10 14:03:10.100' , status = 'open' , value = 'y'
the between operator inclusive include dates above see here - link
edit: removed incorrect statement how between operator works
Comments
Post a Comment