datetime - Conversion failed when converting character string to smalldatetime data type -


select b.value table1 (nolock)  inner join table2 b (nolock) on a.id = b.id     a.name = 'completed_at'      , convert(smalldatetime, a.value) < getdate() - 30     , b.name = 'result' 

getting error message

conversion failed when converting character string smalldatetime data type

when executing above query

example table structure

id  name           value 1   result         r12344 1   completed_at   2015-03-20t06:06:46 2   result         r23445 2   completed_at   2014-03-20t06:06:46 

column value of nvarchar(400) datatype

the query result should display values of result name type have been made entry of more 30 days.

looking forward in hearing you.

it works fine, changed table2 table1, because said self join.

create table table1     ([id] int, [name] varchar(12), [value] varchar(19)) ;  insert table1     ([id], [name], [value]) values     (1, 'result', 'r12344'),     (1, 'completed_at', '2015-03-20t06:06:46'),     (2, 'result', 'r23445'),     (2, 'completed_at', '2014-03-20t06:06:46') ; select b.value table1 (nolock)  inner join table1 b (nolock) on a.id = b.id     a.name = 'completed_at'      , convert(smalldatetime, a.value) < getdate() - 30     , b.name = 'result' 

result

value r23445 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -