Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert date

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-05-03 : 02:50:29
select '"'+column1+'"|"'+column2+'"|"'+date+'"'
from table

i would like to get the date output same as existing

2013-11-03 14:00:00.000

but i get this error:
Conversion failed when converting date and/or time from character string.

Then i tried this

select '"'+column1+'"|"'+column2+'"|"'+convert(nvarchar,date)+'"'
from table

but i get the date format as below:

"Nov 03 2013 14:00AM"

how can i fix so that the date as existing?

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-03 : 02:55:53
select '"'+column1+'"|"'+column2+'"|"'+CONVERT(VARCHAR(23), @date, 121)+'"'
from table



--
Chandu
Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-05-03 : 02:59:26
Got it thanks
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-03 : 03:00:29
quote:
Originally posted by peace

Got it thanks


Welcome


--
Chandu
Go to Top of Page
   

- Advertisement -