3

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

Hadi
  • 36,233
  • 13
  • 65
  • 124
user3868641
  • 162
  • 2
  • 13

2 Answers2

1

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.


Detailed answer

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:

  • Mathematical functions
  • String functions
  • Date and time functions
  • System functions

The following table (official documentation) contains the mathematical functions supported in the SSIS expression language:

enter image description here

Based on that, there is no COS(), SIN() and ACOS() function provided by the SSIS expression language.

Script Component

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:


References

Hadi
  • 36,233
  • 13
  • 65
  • 124
0

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;
    }
}
Hadi
  • 36,233
  • 13
  • 65
  • 124
user3868641
  • 162
  • 2
  • 13