Convert day, hour, minute, second (6d 5h 19m 18s) in Hour’s integer value in SQL Server

manish verma 461 Reputation points
2024-01-23T14:32:18.23+00:00

Hi All, we have a issue to convert Day, Hours, Minute, Second in Hours integer value. This is incoming data format-6d 5h 19m 18s, we need to convert this value in hours as integer value. Thanks MV

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,979 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,653 questions
{count} votes

Accepted answer
  1. LiHongMSFT-4306 27,961 Reputation points
    2024-01-24T01:40:43.31+00:00

    Hi @manish verma

    This is incoming data format-6d 5h 19m 18s, we need to convert this value in hours as integer value.

    As integer value? You can only convert it to decimal in hours, unless you don't need the precision of the data and strip out the minutes and seconds.

    This is incoming data format-6d 5h 19m 18s

    Is this data stored as varchar datatype or others? Please clarify this and post your desired result of conversion.

    Best regards, Cosmog Hong


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.