Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Retrieve a substring Expand / Collapse
Author
Message
Posted Monday, March 04, 2013 3:16 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 5:32 AM
Points: 124, Visits: 324
Dear,
I want to find the time portion from the following string.

"Feb 18 2013 3:35PM"

please tell me the T-SQL to retrieve '3:35PM' as result

Thanks in advance
Post #1426154
Posted Monday, March 04, 2013 3:38 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 10:35 AM
Points: 492, Visits: 2,148
select convert(varchar, cast('Feb 18 2013 3:35PM' as time), 100)



-----------------------------------
http://www.SQL4n00bs.com
Post #1426159
Posted Monday, March 04, 2013 4:15 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, May 08, 2013 5:30 AM
Points: 870, Visits: 522
SUBSTRING ( expression ,start , length )

SELECT SUBSTRING( 'Feb 18 2013 3:35PM', LEN('Feb 18 2013 3:35PM')-7, 6 )
Post #1426170
Posted Monday, March 04, 2013 5:13 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:27 AM
Points: 5,618, Visits: 10,990
SELECT RIGHT('Feb 18 2013 3:35PM',7)


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1426189
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse