sql server - date conversion failed on PROD, working fine in DEV -


i have report stopped working in production, worked fine until few weeks ago. working fine in dev identical code. both environments sql server 2012.

select sum(oi.quantity_shipped) [quantity shipped],     oi.itemdescription [item description],     oi.itemlanguage order_items oi inner join orderx x on oi.id = x.id convert(date, x.shipdate) between '1/1/2016' , '1/1/2017' group oi.itemdescription,     oi.itemlanguage order [item description] 

the prod code returns error:

msg 241, level 16, state 1, line 2 conversion failed when converting date and/or time character string.

note x.shipdate can null. thoughts on causing this?

even though found bad data causing error, here other things keep in mind:

i think might misunderstand between; unless explicitly want include of january 1st, 2017. also, use 'yyyymmdd' string format dates.

applications use other apis, or transact-sql scripts, stored procedures, , triggers, should use unseparated numeric strings. example, yyyymmdd 19980924. - write international transact-sql statements - msdn

select sum(oi.quantity_shipped) [quantity shipped],     oi.itemdescription [item description],     oi.itemlanguage order_items oi inner join orderx x on oi.id = x.id convert(date, x.shipdate,120) >= '20160101'    , convert(date, x.shipdate,120) <  '20170101'  group oi.itemdescription,     oi.itemlanguage order [item description] 

reference:


Comments