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.
Author |
Topic |
dimepop
Starting Member
33 Posts |
Posted - 2013-01-24 : 06:52:14
|
Hi, on the querySelect time from databaseReturns time like 23-Jan-131:30 PMHow can i trim the test so it only returns 1:30 PMSo remove first 9 charactersthanks |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-01-24 : 06:57:45
|
quote: Originally posted by dimepop Hi, on the querySelect time from databaseReturns time like 23-Jan-131:30 PMHow can i trim the test so it only returns 1:30 PMSo remove first 9 charactersthanks
If this is VARCHAR type data, RIGHT(yourVar, 7)--Chandu |
|
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2013-01-24 : 06:59:46
|
select convert(varchar(10), GETDATE(), 108)And check this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=38940 |
|
|
sqlbay
Starting Member
12 Posts |
Posted - 2013-01-24 : 07:04:51
|
SELECT CONVERT(VARCHAR,GETDATE(),100)--OutputJan 24 2013 7:04AMSELECT RIGHT(CONVERT(VARCHAR,GETDATE(),100),8)--Output 7:04AMSQL Server Professional http://sqlbay.blogspot.in |
|
|
dimepop
Starting Member
33 Posts |
Posted - 2013-01-24 : 07:08:01
|
Hi the datatype is smalldatetimeRegards |
|
|
sqlbay
Starting Member
12 Posts |
Posted - 2013-01-24 : 07:40:34
|
RIGHT(CONVERT(VARCHAR,GETDATE(),100),8)Replace GETDATE() with your date column.It should work even for datatype smalldatetimeSQL Server Professional http://sqlbay.blogspot.in |
|
|
dimepop
Starting Member
33 Posts |
Posted - 2013-01-24 : 07:56:40
|
HI, this worked, thanksquote: Originally posted by sqlbay RIGHT(CONVERT(VARCHAR,GETDATE(),100),8)Replace GETDATE() with your date column.It should work even for datatype smalldatetimeSQL Server Professional http://sqlbay.blogspot.in
|
|
|
djj55
Constraint Violating Yak Guru
352 Posts |
Posted - 2013-01-24 : 09:03:22
|
You could also use CAST(yourdatetime AS TIME) if you do not need it as a character string.djj |
|
|
|
|
|
|
|