varChar Time values converted to DateTime to get 24hr time

Following on from my other questions "SQL code to extract 30mins from a varChar data type"

I can get the results I am after the code is a bit messy wondering if it can be done in one chunk without using a temp table.

running this select SeminarTime from dbo.SeminarSMS gives this Output:

SeminarTime
9:30am
12:00pm
3:00pm
4:00pm
9:00am

running the below code gives the desired results just wondering if it could be written better and without using a temp table:
set dateformat dmy
select cast (SeminarTime as datetime) as SeminarTime
into #TimeAsDateTime
from dbo.SeminarSMS
Select
CONVERT(VARCHAR(5)
, dateadd (minute, - 30, SeminarTime), 108) as Time1
, CONVERT(VARCHAR(5), SeminarTime, 108)            as Time2
from #TimeAsDateTime

result:
Time1       Time2
09:00      09:30
11:30      12:00
14:30      15:00
15:30      16:00
08:30      09:00
JCTDDAsked:
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.

appariCommented:
try this

Select
CONVERT(VARCHAR(5)
, dateadd (minute, - 30, cast (SeminarTime as datetime) ), 108) as Time1
, CONVERT(VARCHAR(5), cast (SeminarTime as datetime) , 108)            as Time2
from dbo.SeminarSMS
javaboonCommented:
You can write the whole thing as one query, no need for a temp table at all.

set dateformat dmy
Select
CONVERT(VARCHAR(5)
, dateadd (minute, - 30, cast (SeminarTime as datetime)), 108) as Time1
, CONVERT(VARCHAR(5), cast (SeminarTime as datetime), 108)            as Time2
from dbo.SeminarSMS
cyberkiwiCommented:
You don't even need the first CAST

Select
CONVERT(VARCHAR(5), dateadd (minute, - 30, SeminarTime), 108) as Time1,
CONVERT(VARCHAR(5), cast(SeminarTime as datetime), 108) as Time2
from tbl
cyberkiwiCommented:
nor do you need "set dateformat dmy"
Actually, sorry replace "tbl" with your table name

Select
CONVERT(VARCHAR(5), dateadd (minute, - 30, SeminarTime), 108) as Time1,
CONVERT(VARCHAR(5), cast(SeminarTime as datetime), 108) as Time2
from dbo.SeminarSMS

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
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.