Declare @value nvarchar(100)= 'Generated by [email protected] on 12/5/2014 1:00:13 PM from ATOM.'
Select LEFT(REVERSE(LEFT(REVERSE(RTRIM(@value)), 31)),20)
Now boys and girls, a solution for all date formats as well as variable length suffixes
Declare @values table (value nvarchar(100) NOT NULL);
INSERT @values VALUES
('Generated by [email protected] on 2/2/2014 1:00:13 PM from ATOM.'),
('Generated by [email protected] on 17/2/2014 1:00:13 PM from SOmewhere.'),
('Generated by [email protected] on 2/11/2014 1:00:13 PM from NeverNeverLand.'),
('Generated by [email protected] on 12/11/2014 1:00:13 PM from X.')
SELECT
RTRIM(SUBSTRING(V.value, PATINDEX(X.Pattern, V.value)+1, X.Patlength))
FROM
@values V
JOIN
(
VALUES
('% [1-9]/[1-9]/2[0-3][0-9][0-9]%', 20),
('% [1-3][0-9]/[1-9]/2[0-3][0-9][0-9]%', 21),
('% [1-9]/1[0-2]/2[0-3][0-9][0-9]%', 21),
('% [1-3][0-9]/1[0-2]/2[0-][0-9][0-9]%', 22)
) X (Pattern, Patlength) ON PATINDEX(X.Pattern, V.value) > 0