Converting a Character String into a Time Field

Question:
How do I convert a character string into a time field? Data is being read in as 12:10 and I need to calculate response times based on this field.

Answer:
Try this:

 SELECT CONVERT(CHAR(15), getdate())

or going the other way:

 SELECT CONVERT(DATETIME, "12/10/99")

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist