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)
 date conversion

Author  Topic 

xyz7767
Starting Member

4 Posts

Posted - 2010-08-16 : 20:19:57
Please advise how to convert date in mm/dd/yyyy hh:mm:ss format

namman
Constraint Violating Yak Guru

285 Posts

Posted - 2010-08-16 : 23:50:28
Surprise, no body help you ....

SELECT GETDATE() AS DEFAULT_FORMAT, CONVERT(VARCHAR(20), GETDATE(), 120) AS [MM/DD/YYYY HH:MM:SS]
SELECT CONVERT(VARCHAR(23), GETDATE(), 121) AS [MM/DD/YYYY HH:MM:SS:MMM]
SELECT CONVERT(VARCHAR(20), GETDATE(), 120) AS [MM/DD/YYYY HH:MM:SS]
SELECT CONVERT(VARCHAR(16), GETDATE(), 120) AS [MM/DD/YYYY HH:MM]
SELECT CONVERT(VARCHAR(23), GETDATE(), 101) AS [MM/DD/YYYY]
SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY]
SELECT CONVERT(VARCHAR(12), GETDATE(), 114) AS [HH:MM:SS:MMM]
SELECT CONVERT(VARCHAR(8), GETDATE(), 114) AS [HH:MM:SS]
SELECT CONVERT(VARCHAR(5), GETDATE(), 114) AS [HH:MM]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-08-17 : 02:02:33
quote:
Originally posted by xyz7767

Please advise how to convert date in mm/dd/yyyy hh:mm:ss format


Where do you want to show formatted dates?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-17 : 10:30:06
quote:
Originally posted by xyz7767

Please advise how to convert date in mm/dd/yyyy hh:mm:ss format


This is a formatting issue. So please try to do it at front end as far as possible. Even most of reporting tools have date formatting functions built in it so don't change datatype while retrieving from table just for formatting.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -