Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date formatting in Stored Procedure 2

Status
Not open for further replies.

aaronjonmartin

Technical User
Jul 9, 2002
475
GB
I have a table which contains a column which is a datetime column, and contains dates in the format dd/mm/yy hh:mm:ss.

I am using a stored procedure to select the dates from this table. However i wish to format them differently. I want the stored procedure to change the formatting of the dates to mm/dd/yy hh:mm:ss. Is this possible? I dont want to change them in the database, just the format they are returned in from this one stored procedure.

Any help with this would be most appreciated.

Aaron

"It's so much easier to suggest solutions when you don't know too much about the problem."
Malcolm Forbes (1919 - 1990)
 
select CONVERT(varchar(30),getdate(),09) as 'mon dd yyyy hh:mi:ss:mmmAM (or PM)'

select CONVERT(varchar(10),getdate(),101) as 'mm/dd/yyyy'
select CONVERT(varchar(8),getdate(),108) as 'hh:mm:ss'

select CONVERT(varchar(10),getdate(),101) + ' ' + CONVERT(varchar(8),getdate(),108) as 'mm/dd/yyyy hh:mm:ss'
 
> I have a table which contains a column which is a datetime column, and contains dates in the format dd/mm/yy hh:mm:ss.

<preachin'>
Datetime is NOT stored in any particular format. See faq183-5834.

Unless you do export to text files or something, such things (presentation) are best done outside database. There are good reasons why is that so.
</preachin'>

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
excellent thankyou guys

&quot;It's so much easier to suggest solutions when you don't know too much about the problem.&quot;
Malcolm Forbes (1919 - 1990)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top