troubleshooting Question

Converting a VARCHAR into DATETIME format

Avatar of PROJHOPE
PROJHOPE asked on
Microsoft SQL Server
7 Comments1 Solution1191 ViewsLast Modified:
Stumped on this...I am trying to do some reporting off of a badly designed database.

I have a column called 'Hours'.  The column is VARCHAR (10) and the data is formatted 00:00

Since it is VARCHAR I am unable to sum up the total grouped by employee.

I am looking to take the column 'Hours' and convert from VARCHAR to DATETIME.  I have tried REPLACE, CONVERT, SUBSTRING and I guess I am just not getting the right combination of syntax.  I have tried to strip the column into two columns and sum hours and minutes but then I would need some time of calculation to rollover 60 minutes as an hour...too confusing.

So visually I need this

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros