i have a table in sql server 2012, with one of its column having the following data in time datatype, How would you convert 00:45:00 to 0.45 or 01:45:00 to 1.45 ?
please help.
i have a table in sql server 2012, with one of its column having the following data in time datatype, How would you convert 00:45:00 to 0.45 or 01:45:00 to 1.45 ?
please help.
From the question, it seems you only want to remove the ':' with '.'. If so, it can be achieved in many ways in sql server 2012. One example is below.
If your column is 'Datetime', use this: SELECT REPLACE(LEFT(CAST(DatetimeCol AS TIME),5),':',',') FROM Tbl
Else if it just 'Time' then remove the casting.
You could do arithmetic such as:
But as noted in the comments, "1.45" seems quite confusing. Most people think this should be "1.75". If you want the latter -- with precision to the minute -- you can do:
You know that decimal value of 1:45:00 is 1.75h
try this if you want to convert time to decimal
But if you getting value as par your requirement then try this way