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)
 Need help Date Format

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-07-18 : 09:09:04
I've DateTime field as follow,
7/17/2010 7:45:12 AM

Currently, my SQL as follow
select CONVERT(varchar, t2.LastMaintDte, 4) AS LastMaintDte


Output as follow,
17.07.10


How to make it output as follow,
17.07.10 7:45AM

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-18 : 10:03:58
[code]
select convert(varchar(20), getdate(), 4)
+ right(convert(varchar(19), getdate(), 0), 8)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-07-18 : 10:08:57
tq sir
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-18 : 10:24:22
you are welcome


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-19 : 07:07:34
Also make sure to read this
http://beyondrelational.com/blogs/madhivanan/archive/2010/06/29/understanding-datetime-column-part-iv.aspx

Madhivanan

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

- Advertisement -