Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sanghavi17389
Starting Member
26 Posts |
Posted - 2012-05-18 : 10:07:28
|
My purpose is to find out time difference.eg:time1 = 22:32:34 = ((22)*60*60) + (32*60) + 34 = 81154time2 = 3:03:46 = (3*60*60) + (3*60) + 46 = 11026time1-time2 = 81154 - 11026 = 70128 CONVERT DIFFERENCE TO H:M:S1) Convert to minutes and seconds70128 / 60 = 1168 //integer division, number of minutes70128 % 60 = 48 //modulus, number of seconds left2) Convert minutes to hours1168 / 60 = 19 //integer division, number of hours1168 % 60 = 28 //modulus, remaining minutesTime difference is then 19 hrs, 28 minutes, 48 seconds.harshal sanghaviedit: moved to proper forum |
|
influent
Constraint Violating Yak Guru
367 Posts |
Posted - 2012-05-18 : 18:02:45
|
Does this help?TheTime = convert(varchar, convert(int,floor(TimeCol)))+ ':'+ replicate('0',(2 - len(convert (varchar, convert(int,(TimeCol - floor(TimeCol)) * 60.0)))))+ convert (varchar, convert(int,(TimeCol - floor(TimeCol)) * 60.0)) |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-05-18 : 18:19:35
|
This works in the expression builder:=DateAdd("s",DateDiff("s",Fields!date2.Value,Fields!date1.Value),"1/1/1900")You'll have to set a number format of Time to get the correct display. The field values also have to be time data type, or if they're datetime, have the same date portion. |
|
|
|
|
|
|
|