Home > database >  Consult MSSQL stored procedure development problems
Consult MSSQL stored procedure development problems

Time:10-28

Is like that, I now have a demand, I want to use stored procedures to calculate a equipment failure rate, the calculation formula is: (1 - (single fault theory of total time/total elapsed time)), in Excel calculation is very simple, division by two time can directly, but inside a stored procedure should do? I the time here is time, minutes, seconds spell with a colon, pick up

My train of thought is that the inside a stored procedure in the time (format such as: 15:00:00) converted to decimal, then two decimal division, then convert hundreds of points, but now I don't know how to put the time into decimal, please everyone a great god help!

CodePudding user response:

Are the requirements for 15:00:00 is time, the calculation of you, the length,

CodePudding user response:

I described is wrong, it is calculated according to the length, how long I can already calculate now, but how failure rate is calculated according to the length, or how to convert the length to the decimal,

CodePudding user response:

DATEDIFF (datepart, startdate, enddate)

Startdate and enddate parameters is the date of the legitimate expression,
Datepart parameters can be the following value:
Datepart abbreviation
In yy, yyyy
Quarter of qq, q
Mm, m
Day of the year dy, y
Dd, d
Week of wk, a ww
Week dw, w
Hours of hh
Minutes of mi, n
Ss, s
Ms ms
Subtle MCS
A nanosecond ns

Put your time range into a time interval, that is, how to do calculations
  • Related