GRAMS
Updated 2023-11-09 19:07:48.667000
Syntax
SELECT [westclintech].[wct].[GRAMS] (
<@Weight, float,>
,<@From_scale, nvarchar(4000),>
,<@To_scale, nvarchar(4000),>)
Description
Use the scalar function GRAMS to convert from drams, grains, grams, hundredweights, ounces, pennyweights, pounds, stones, tonnes, tons, troy pounds or troy ounces to troy pounds.
Arguments
@From_scale
is the description of the units for @Weight. @From_scale must be a valid value as specified in weight unit representations. @From_scale must be of a data type that is implicitly convertible to varchar.
@Weight
is any real number. @Weight is an expression of type float or of a type that can be implicitly converted to float.
@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 weight unit representations. In addition to grams, @To_scale can be decigrams, centigrams, milligrams, micrograms, nanograms, picograms, femtograms, attograms, zeptograms, yoctograms, decagrams, hectograms or kilograms. @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 weight units of measure into grams:
{"columns":[{"field":"column 1"},{"field":"column 2","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"grains","column 2":"0.06479891000"},{"column 1":"drams","column 2":"1.7718452"},{"column 1":"ounces avoirdupois","column 2":"28.34952"},{"column 1":"pounds avoirdupois","column 2":"453.59237"},{"column 1":"stones","column 2":"6350.29318"},{"column 1":"hundredweights","column 2":"45359.237"},{"column 1":"tons","column 2":"907184.74"},{"column 1":"pennyweights","column 2":"1.55517384"},{"column 1":"ounces troy","column 2":"31.1034768"},{"column 1":"pounds troy","column 2":"373.2417216"},{"column 1":"grams","column 2":"1"},{"column 1":"tonnes","column 2":"1000000"}]}
Conversion of grams includes all the standard prefixes with kilo representing 1,000 and yocto representing 10E-24.
Examples
select wct.GRAMS(100, 'lbs', 'kg');
Here is the result set.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"45.359237"}]}