sql server 2008 - sql combining two columns one of which is a datetime -


i have following sql code (ms sql server 2008)

select (analysisno + ' ' + '-' + ' ' + description + ' ' + '-' + ' ' + formdate) columna  

from old_analysis_data order formdate

i following error conversion failed when converting date and/or time character string.

analysisno varchar(10) description varchar(500) formdate datetime (not table, old one)

any ideas, cant find answer on google.

convert time string using convert before concatenation:

select ( analysisno + ' ' + '-' + ' ' + description + ' ' + '-' + ' '       + convert(varchar(20), formdate, 100) ) columna        old_analysis_data  order       formdate 

in case, 100 style sets datestamp format mon dd yyyy hh:miam (or pm) example

see http://www.w3schools.com/sql/func_convert.asp


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -