Logo

SQL Server LITERS Function

Updated 2023-11-09 16:25:33.283000

Description

Use the scalar function LITERS to convert from barrels (US beer barrels), bbl (oil barrel), bushels, cubic feet, cubic inches, cubic meters, cubic miles, cubic yards, cups, dry pints, dry quarts, fluid drams, fluid ounces, gallons, gills, imperial gallons, imperial gills, imperial pints, imperial quarts, liters, pecks, pints, quarts, steres, tablespoons or teaspoons to liters.

Syntax

SELECT [westclintech].[wct].[LITERS] (
  <@Volume, float,>
 ,<@From_scale, nvarchar(4000),>
 ,<@To_scale, nvarchar(4000),>)

Arguments

@Volume

is any real number. @Volume 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 @Volume. @From_scale must be a valid value as specified in volume unit representations. @From_scale must be of a data type that is implicitly convertible to varchar.

@To_scale

is the description of the units for that @Volume is to be converted into. @To_scale must be a valid value as specified in volume unit representations. In addition to liters, @To_scale  can be deciliters, centiliters, milliliters, microliters, nanoliters, picoliters, femtoliters, attoliters, zeptoliters, yoctoliters, decaliters, hectoliters or kiloliters. @To_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 volume units of measure into liters:

column 1column 2
teaspoon0.004928922
tablespoon0.01478676
fluid dram0.003696691
fluid ounce0.02957353
cup0.2365882
pint0.4731765
quart0.9463529
gallon3.785412
cubic inch0.01638706
cubic foot28.31685
cubic yard764.5549
cubic mile4.16818E+12
imperial ounce0.02841306
imperial pint0.568261485
imperial quart1.13652297
imperial gallon4.54609188
barrel (beer)117.347772
barrel (oil)158.987304
bushel35.23907
gill0.1182941
imperial gill0.1420653
peck8.809768
dry pint0.5506105
dry quart1.101221
stere1000
liter1
cubic meter1000

Conversion of metric values (liters and cubic meters) includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.

Examples

select wct.LITERS(1, 'quart', 'liters');

Here is the result set.

column 1
0.9463529