SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

391 Posts

Posted - 05/03/2013 :  02:50:29  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2202 Posts

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



--
Chandu
Go to Top of Page

peace
Constraint Violating Yak Guru

391 Posts

Posted - 05/03/2013 :  02:59:26  Show Profile  Reply with Quote
Got it thanks
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2202 Posts

Posted - 05/03/2013 :  03:00:29  Show Profile  Reply with Quote
quote:
Originally posted by peace

Got it thanks


Welcome


--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000