Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have a table and i want to update all the rows of Duration Column which is in Decimal format to HH:MM Format.


ECodeDuration
101101.75
10169.56
10254.97
10435.32


the out put should be like this:-

ECodeDuration
101102.15
101 69.56
10255.37
10435.32

We are calculating the time after the decimal and if after decimal 60 or more then 60 will be there we are adding 1 before decimal and remaining after subtraction from 60 we are showing as it is.Example 101.75 , here after decimal 75 is there so firstly we check it is gtreater then and equal to 60 .if yes then subtract 60 and add 1 before decimal and put the remaining 15 after decimal.so the result become 102.15.
Please share the query if possible so that i will update all rows of the table and get the desired result.
Posted
Updated 29-Feb-12 22:49pm
v2
Comments
The Doer 1-Mar-12 4:02am    
how your duration changes from 101.75 to 102.15???????/
Dharmenrda Kumar Singh 1-Mar-12 4:49am    
We are calculating the time after the decimal and if after decimal 60 or more then 60 will be there we are adding 1 before decimal and remaining after subtraction from 60 we are showing as it is.Example 101.75 , here after decimal 75 is there so firstly we check it is gtreater then and equal to 60 .if yes then subtract 60 and add 1 before decimal and put the remaining 15 after decimal.so the result become 102.15.
Dharmenrda Kumar Singh 1-Mar-12 4:25am    
After the Decimal we have .75 so .60=1 Min and thats why 101.75 will become 102.15.
Nilesh Patil Kolhapur 1-Mar-12 5:00am    
use trigger before insert

1 solution

SQL
update Table set duration = duration + 0.4 where duration - floor(duration) >= 0.6


This Query had solved my problem.
 
Share this answer
 
Comments
Nilesh Patil Kolhapur 1-Mar-12 6:02am    
Nice answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900