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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Altering result-set DATETIME format?

Author  Topic 

woolyg
Starting Member

3 Posts

Posted - 2007-06-14 : 19:29:51
Hello all - great to find a community resource of this magnitude based around SQL!

I'm running a query that shows an account activation time and I need to format the results as M/D/Y hh:mm:ss

The way it is displayed by default is YYYY-MM-DD hh:mm:ss:.000 (eg 2007-06-30 04:32:00.000)

Is there a way of doing this?

All help appreciated guys.
Woolyg

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-06-14 : 19:31:14
Where do you want the results to be formatted? Just return the date "as is" from SQL and let your front-end application format that date. SQL is not a presentation language, it is a data manipulation and retrieval language.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

woolyg
Starting Member

3 Posts

Posted - 2007-06-14 : 21:06:33
I'm actually outputting to CSV text from an SQL application's DB. From that text, I'll be importing the CSV text back in using XML, but the app's XML import utility requires the account activation text to be formatted as M/D/Y hh:mm:ss.

Am I barking up the wrong tree?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-14 : 21:14:02
use convert() to format it.
select convert(varchar(30), datecol, 101) + ' ' + convert(varchar(20), datecol, 108)



KH

Go to Top of Page

woolyg
Starting Member

3 Posts

Posted - 2007-06-14 : 21:31:48
khtan - Thank you so much. That is an amazing help!

Thank you both for your help! Woolyg.
Go to Top of Page
   

- Advertisement -