I'm trying to calculate SIN and COS in SSIS expression (as new column), but I cannot find any expression.
For example:
SIN(lat_org_rad) COS(long_org_rad) ACOS(long_org_rad)
Could anybody help me?
Thanks
I'm trying to calculate SIN and COS in SSIS expression (as new column), but I cannot find any expression.
For example:
SIN(lat_org_rad) COS(long_org_rad) ACOS(long_org_rad)
Could anybody help me?
Thanks
TLDR: COS()
, SIN()
, ACOS()
cannot be achieved using SSIS expression you have to write a script component to achieve that using System.Math assembly which is apart of the .NET framework.
I am writing this answer as additional information for the answer written by the OP:
The SSIS expression language includes a set of functions for use in expressions, and they can be categorized into the following groups:
The following table (official documentation) contains the mathematical functions supported in the SSIS expression language:
Based on that, there is no COS()
, SIN()
and ACOS()
function provided by the SSIS expression language.
On the other hand you can benefit from the Script Component transformation for more advanced mathematical functions using System.Math assembly which contains advanced methods that are listed in the following documentation:
I was able to solve the issue using a Script component:
public override void Entrada0_ProcessInputRow(Entrada0Buffer Row)
{
if (Row.latdestrad == 0)
{
Row.kms = 0;
}
else
{
Row.kms = Math.Acos(
(Math.Sin(Row.latorgrad) * (Math.Sin(Row.latdestrad))) +
(Math.Cos(Row.latorgrad) * (Math.Cos(Row.latdestrad)) * Math.Cos(Row.londestrad - Row.lonorgrad)))
* 57.29577951 * 111.302;
}
}