How to split date from string data

I have these kind of data from a varchar column:
Recommended By: Jegonia, Erika @ 9/16/2006 10:07:48 AM
Approved By: Jegonia, Jimi @ 7/7/2006 8:09:00 AM

How can split them so I can get both values:
Sample 1:
-LDate = 9/16/2006 10:07:48 AM
-SDate = 9/16/2006

Sample 2:
-LDate = 7/7/2006 8:09:00 AM
-SDate = 7/7/2006

Thanks
JaimeJegoniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pratima PharandeCommented:
try like this

Declare @str varchar(100)
set @str = 'Jegonia, Erika @ 9/16/2006 10:07:48 AM'
SELECT Right(@str,Len(@str) - CHARINDEX ( '@', @str)) as LDate ,
Substring(@str,CHARINDEX ( '@', @str)+2,10) as Sdate
0
Pratima PharandeCommented:
Declare @str varchar(100)
set @str = 'Jegonia, Erika @ 1/1/2006 10:07:48 AM'
SELECT Right(@str,Len(@str) - CHARINDEX ( '@', @str)) as LDate ,
Substring(@str,CHARINDEX ( '@', @str)+2,CHARINDEX ( ':', @str)-CHARINDEX ( '@', @str)-4) as Sdate
0
JaimeJegoniaAuthor Commented:
How can I dynamically refer to the column name (say ApprovedDate) and I dont want to declare anything. I want to be able to create a new concatenated column.

Thanks
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

JaimeJegoniaAuthor Commented:
I tried to substitute @str with AppNameAndDate in the view grid as follows and I got the attached error:

SELECT SUBSTRING(AppNameAndDate, CHARINDEX('@', AppNameAndDate) + 2, CHARINDEX(':', AppNameAndDate) - CHARINDEX('@', AppNameAndDate)
               - 4) AS SDate, RIGHT(AppNameAndDate, LEN(AppNameAndDate) - CHARINDEX('@', AppNameAndDate)) AS LDate
FROM  dbo.tblPR


SQLError.JPG
0
JaimeJegoniaAuthor Commented:
With this one, I'm actually getting the long date right.
RIGHT (AppNameAndDate, LEN(AppNameAndDate) - CHARINDEX('@', AppNameAndDate))

Now, Is there an MS SQL function to convert or format to make that long date to short date?

Thanks  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaimeJegoniaAuthor Commented:
Dear Moderator,

please remove this question - I have changed my approach to go on.

Thanks

Jimi Jegonia
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.