| Author |
Topic  |
|
|
dimepop
Starting Member
30 Posts |
Posted - 01/24/2013 : 06:52:14
|
Hi, on the query Select time from database Returns time like 23-Jan-131:30 PM
How can i trim the test so it only returns 1:30 PM So remove first 9 characters thanks |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1416 Posts |
Posted - 01/24/2013 : 06:57:45
|
quote: Originally posted by dimepop
Hi, on the query Select time from database Returns time like 23-Jan-131:30 PM
How can i trim the test so it only returns 1:30 PM So remove first 9 characters thanks
If this is VARCHAR type data, RIGHT(yourVar, 7)
-- Chandu |
 |
|
|
jafrywilson
Constraint Violating Yak Guru
India
379 Posts |
|
|
sqlbay
Starting Member
12 Posts |
Posted - 01/24/2013 : 07:04:51
|
SELECT CONVERT(VARCHAR,GETDATE(),100) --Output Jan 24 2013 7:04AM
SELECT RIGHT(CONVERT(VARCHAR,GETDATE(),100),8) --Output 7:04AM
SQL Server Professional http://sqlbay.blogspot.in |
 |
|
|
dimepop
Starting Member
30 Posts |
Posted - 01/24/2013 : 07:08:01
|
Hi the datatype is smalldatetime Regards |
 |
|
|
sqlbay
Starting Member
12 Posts |
Posted - 01/24/2013 : 07:40:34
|
RIGHT(CONVERT(VARCHAR,GETDATE(),100),8)
Replace GETDATE() with your date column.It should work even for datatype smalldatetime
SQL Server Professional http://sqlbay.blogspot.in |
 |
|
|
dimepop
Starting Member
30 Posts |
Posted - 01/24/2013 : 07:56:40
|
HI, this worked, thanks
quote: Originally posted by sqlbay
RIGHT(CONVERT(VARCHAR,GETDATE(),100),8)
Replace GETDATE() with your date column.It should work even for datatype smalldatetime
SQL Server Professional http://sqlbay.blogspot.in
|
 |
|
|
djj55
Yak Posting Veteran
USA
84 Posts |
Posted - 01/24/2013 : 09:03:22
|
You could also use CAST(yourdatetime AS TIME) if you do not need it as a character string.
djj |
 |
|
| |
Topic  |
|