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)
 Convert datetime code

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-12-22 : 10:07:05
What code should I use to get 12/22/2009 10:04AM?
I used code below but get 'Dec 22 2009 10:03AM'

select convert(varchar(20),GETDATE(),100)

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-22 : 10:18:06
I dont know of a direct convert option...but maybe this..
select convert(varchar(20),getdate(),101) + right(convert(varchar(20),getdate(),100),8)
Go to Top of Page

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-12-22 : 11:05:55
It works fine.
Thank you.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-22 : 11:11:23
You're welcome.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-23 : 02:01:33
IKf you want to show formatted dates in front end application, do formation there

Madhivanan

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

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-12-23 : 04:01:57
Hi foster,
go through these links it may help you in further
http://www.sql-server-helper.com/tips/date-formats.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563
Go to Top of Page
   

- Advertisement -