Login     Register

        Contact Us     Search

XLeratorDB/engineering Online Documentation

SQL Server function to convert volume to gallons


GALLONS
 
Updated: 01 December 2008 

Use GALLONS 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 gallons.
Syntax
SELECT [westclintech].[wct].[GALLONS] (
  <@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 Types
float
Remarks
·         The following table is a representation of the conversion of one of the volume units of measure into gallons:
teaspoon
0.001302083
tablespoon
0.00390625
fluid dram
0.000976563
fluid ounce
0.0078125
cup
0.0625
pint
0.125
quart
0.25
gallon
1
cubic inch
0.004329004
cubic foot
7.48051948
cubic yard
201.974026
cubic mile
1.10112E+12
imperial ounce
0.00750594
imperial pint
0.150118803
imperial quart
0.300237605
imperial gallon
1.20095042
barrel (beer)
31
barrel (oil)
42
bushel
9.30917797
gill
0.03125
imperial gill
0.037529701
peck
2.32729449
dry pint
0.145455899
dry quart
0.290911797
stere
264.172052
liter
0.264172052
cubic meter
264.172052
 
·         Conversion of metric values (liters and cubic meters) includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Example
 
select wct.GALLONS(1, 'quart')
Here is the result set
----------------------
0.25
 
(1 row(s) affected)


Copyright 2008-2017 Westclintech LLC         Privacy Policy        Terms of Service