SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,708 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
My table lists the date and time fields as integer data types. I need to convert them to normal date formats. I have the date field done. How can I convert the time field with SQL?
To make a datetime from your two integers, try this expression:
cast(concat(AppointmentDate, ' ', AppointmentTime / 100, ':', AppointmentTime % 100) as datetime)
If you need just the time:
timefromparts(AppointmentTime / 100, AppointmentTime % 100, 0, 0, 0)
Use these expressions in SELECT or UPDATE statements.