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
 General SQL Server Forums
 New to SQL Server Programming
 How to remove the seconds

Author  Topic 

richardlaw
Yak Posting Veteran

68 Posts

Posted - 2009-01-11 : 05:15:02
Hi

I'm using the following code to extract just the time, but how can I remove the seconds???

SELECT CONVERT(varchar(10), DOB, 108) AS Expr1
FROM dbo.tblGymnasts

Many thanks
Richard

Richard Law

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-11 : 05:22:25
try this

solution 1:

SELECT LEFT(CONVERT(varchar(10), dob, 108),5) AS Expr1
FROM dbo.tblGymnasts


solution 2:


SELECT CONVERT(varchar(5), dob, 108) AS Expr1
FROM dbo.tblGymnasts

Go to Top of Page

richardlaw
Yak Posting Veteran

68 Posts

Posted - 2009-01-11 : 05:44:19
Perfect - Solution 1 works great - thank you!
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-11 : 05:45:36
quote:
Originally posted by richardlaw

Perfect - Solution 1 works great - thank you!



welcome....

Solution 2 also works for u..try it.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-11 : 07:00:59
quote:
Originally posted by richardlaw

Hi

I'm using the following code to extract just the time, but how can I remove the seconds???

SELECT CONVERT(varchar(10), DOB, 108) AS Expr1
FROM dbo.tblGymnasts

Many thanks
Richard

Richard Law


where are you using this value? is it for display or for calculation?
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2009-01-11 : 19:24:11
i think for display only :)

RON
________________________________________________________________________________________________
"I won't last a day without SQL"




Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-11 : 23:03:05
try this richardlaw,
select right(convert(varchar(32),dob),7)FROM dbo.tblGymnasts

select substring(convert(varchar(32),dob),12,5)FROM dbo.tblGymnasts
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-12 : 02:16:06
quote:
Originally posted by cwtriguns2002

i think for display only :)

RON
________________________________________________________________________________________________
"I won't last a day without SQL"







then consider doing this at your front end.
Go to Top of Page
   

- Advertisement -