Logo

SQL Server MIHR Function

Updated 2023-11-09 14:48:38.203000

Description

Use the scalar function MIHR to convert from feet per hour, feet per minute, feet per second, inches per second, kilometers per hour, knots, miles per hour, miles per minute, miles per second, meters per second, meters per minute or meters per hour to miles per hour.

Syntax

SELECT [westclintech].[wct].[MIHR] (
  <@Speed, float,>
 ,<@From_scale, nvarchar(4000),>)

Arguments

@Speed

is any real number. @Speed is an expression of type float or of a type that can be implicitly converted to float.

@From_scale

is the description of the units for @Speed. @From_scale must be a valid value as specified in speed unit representations. @From_scale must be of a data type that is implicitly convertible to varchar.

Return Type

float

Remarks

The following table is a representation of the conversion of one of the speed units of measure into miles per hour:

column 1column 2
feet per hour0.000189393939
feet per minute0.0113636364
feet per second0.681818182
inches per second0.0568181818
kilometers per hour0.621371192
knots1.15077945
miles per hour1
miles per minute60
miles per second3600
meters per second2.23693629
meters per minute0.0372822715
meters per hour0.000621371192

Conversion of meters includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.

Examples

SELECT n.UOFM,
       wct.MIHR(1, n.UOFM)
from
(
    SELECT 'feet per hour'
    UNION ALL
    SELECT 'feet per minute'
    UNION ALL
    SELECT 'feet per second'
    UNION ALL
    SELECT 'inches per second'
    UNION ALL
    SELECT 'kilometers per hour'
    UNION ALL
    SELECT 'knots'
    UNION ALL
    SELECT 'miles per hour'
    UNION ALL
    SELECT 'miles per minute'
    UNION ALL
    SELECT 'miles per second'
    UNION ALL
    SELECT 'meters per second'
    UNION ALL
    SELECT 'meters per minute'
    UNION ALL
    SELECT 'meters per hour'
) n(UOFM);

Here is the result set.

UOFM
feet per hour0.000189393939
feet per minute0.0113636364
feet per second0.681818182
inches per second0.0568181818
kilometers per hour0.621371192
knots1.15077945
miles per hour1
miles per minute60
miles per second3600
meters per second2.23693629
meters per minute0.0372822715
meters per hour0.000621371192