Logo

SQL Server IMPGALLONS Function

Updated 2023-11-09 16:20:46.373000

Description

Use the scalar function IMPGALLONS 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 imperial gallons.

Syntax

SELECT [westclintech].[wct].[IMPGALLONS] (
  <@Volume, float,>
 ,<@From_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.

Return Type

float

Remarks

The following table is a representation of the conversion of one of the volume units of measure into imperial gallons:

column 1column 2
teaspoon0.001084
tablespoon0.003253
fluid dram0.000813
fluid ounce0.006505
cup0.052042
pint0.104084
quart0.208168
gallon0.832674
cubic inch0.003605
cubic foot6.228833
cubic yard168.1785
cubic mile9.17E+11
imperial ounce0.00625
imperial pint0.125
imperial quart0.25
imperial gallon1
barrel (beer)25.81289
barrel (oil)34.9723
bushel7.751509
gill0.026021
imperial gill0.03125
peck1.937877
dry pint0.121117
dry quart0.242235
stere219.9692
liter0.219969
cubic meter219.9692

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.IMPGALLONS(1, 'quart');

Here is the result set.

column 1
0.20816846