On 9 May 2005 09:04:05 -0700, laurenq uantrell wrote:
Is here an easy way to get 9:00 PM from 5/1/2005 9:00:00 PM without
doing:
Cast(DATEPART(HOUR,xDate) as varchar(2)) + ':' +
Cast(DATEPART(MINUTE,xDate) as varchar(2))
lq
Hi lq,
Check out the various style options described under CONVERT in Books
Online. Depending on the formatting required, you could use one of the
examples below, or change them to your needs:
SELECT CONVERT(char(12), CURRENT_TIMESTAMP, 114)
SELECT SUBSTRING(CONVERT(char(23), CURRENT_TIMESTAMP, 121), 12, 12)
SELECT SUBSTRING(CONVERT(char(19), CURRENT_TIMESTAMP, 100), 13, 7)
SELECT SUBSTRING(CONVERT(char(25), CURRENT_TIMESTAMP, 131), 12, 14)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)