sql server - Getting Error when converting to datetime :Date Column + Time Column -


below sql query, inner query returning value outer query returning error: "conversion failed when converting character string smalldatetime data type. "

select x.* (     select       convert(smalldatetime, convert(varchar(30), convert(date, event_date, 101)) +       convert(varchar(30), ' ') + convert(varchar(30), convert(time, event_time)), 101)         ,[event_date]         ,location         ,street         ,city         ,[state]         ,country         ,zipcode         ,[subject]         ,[detail]         ,[leadinstructor]         ,[coinstructor]     [temp_evt_event]     ) x 

smalldate can accept time value upto 18:00:00. used time format 18:00:00.000000 why show error. check query , update status.

first run query separately:

  select       convert(smalldatetime, convert(varchar(30), convert(date, cast('2014-11-14' datetime), 101)) +       convert(varchar(30), ' ') + convert(varchar(30), convert(varchar(8), cast('18:13:04' datetime), 108)), 101) column1 

if answer. '2014-11-14 18:13:00'

then try run:

 select           convert(smalldatetime, convert(varchar(30), convert(date, cast(event_date datetime), 101)) +           convert(varchar(30), ' ') + convert(varchar(30), convert(varchar(8), cast(event_time datetime), 108)), 101) column1 temp_evt_event 

if answer correctly. run:

 select x.* (     select       convert(smalldatetime, convert(varchar(30), convert(date, cast(event_date datetime), 101)) +       convert(varchar(30), ' ') + convert(varchar(30), convert(varchar(8), cast(event_time datetime), 108)), 101) column1         ,[event_date]         ,location         ,street         ,city         ,[state]         ,country         ,zipcode         ,[subject]         ,[detail]         ,[leadinstructor]         ,[coinstructor]     [temp_evt_event]     ) x 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -