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 2008 Forums
 Transact-SQL (2008)
 Datetime conversion Format dd/mm/yyyy hh:mm:ss AM

Author  Topic 

Kalaiselvan
Posting Yak Master

112 Posts

Posted - 2011-03-11 : 01:30:26
SELECT GETDATE() = 2011-03-11 11:59:29.703

I need the above format as = 11/03/2011 11:59:29 AM


Please help me in finding this conversion.....

Regards,
Kalaiselvan R
Love Yourself First....

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2011-03-11 : 02:26:01
you can find all the different string representations of dates here: http://msdn.microsoft.com/en-us/library/ms187928.aspx


elsasoft.org
Go to Top of Page

Kalaiselvan
Posting Yak Master

112 Posts

Posted - 2011-03-11 : 02:55:47
Not got my exact format from the link. I have already checked the link too.

Reply me with right syntax. Upto now am using this syntax for this solution.

Select Convert(varchar , Getdate(),103) + ' ' + Convert(varchar , Getdate(),108)+ ' ' + SUBSTRING(CONVERT(varchar(20), GETDATE(), 22), 18, 3)

But i need the reply as simple way with simple conversion factor...


Regards,
Kalaiselvan R
Love Yourself First....
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-03-11 : 10:17:15
Why does the formation matter in sql? If you want to show data in front end application, do formation there

Madhivanan

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

michael.appleton
Posting Yak Master

160 Posts

Posted - 2011-03-11 : 10:38:32
Almost every week this kind of question seems to be asked. The correct answer as madhivanan said is it should be done in the application. Store date and time data as datetime and forget about doing anything in the database concerning format conversions!
Go to Top of Page
   

- Advertisement -