Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Example
In this example, we will pass a string value to the function transformation object using a Variables object.
Where,
value = 12345.123
In the output window, you can see that the provided string has been converted into an integer, and its data type has also been converted to Integer.
Example
We have an Orders dataset with the OrderDate field.
In this example, we will pass this field to the function transformation object to get the date components.
Note: The GetDateComponents (DateTimeWithOffset dateTime) function differs from the GetDateComponents(Date dateTime) function as it includes a Timezone Offset value. The Offset value is the number of hours or minutes a time zone is ahead of or behind GMT (Greenwich Mean Time).
Right-click on the function transformation object and select Preview Output. In the output, you can see that each date from the OrderDate field has been separated in the different date components.
Name
ToInteger
Syntax
ToInteger (Any value)
Purpose
To convert a value into integer.
Description
Returns an integer representing the specified value. Returns null if the value cannot be converted to an integer.
Return Type
Integer
Parameters
value [System.Object] – Value to be converted
Name
GetDateComponents
Syntax
GetDateComponents (DateTimeWithOffset dateTime)
Purpose
To return a structure providing individual date components.
Description
Gets a structure representing individual date components.
Return Type
DateComponents
Parameters
dateTime [System.DateTimeOffset] – Date time for which components are required
Example
In this example, we are passing a valid hex value to the function transformation object using a Variables object.
Where,
Value = F
In the output window, you can see that the Integer value 15 has been returned, corresponding to the provided hex value, F.
Example
We have an Orders dataset with a ShippedDate field.
In this example, we will map this field to the string input of the function transformation object. We will also pass a specific date time format, to match the date format of the ShippedDate field, to the Format1 field in the function transformation object using a Variables object.
Where,
Format1 = dd/MM/yyyy hh:mm:ss tt
In the output window, you can see values from the ShippedDate field have been successfully parsed by the function transformation object, as the provided date time format has been matched.
Example
In this example, we are passing a date time value in a format NOT present in the acceptable date time formats list in Astera Data Stack, to the function transformation object using a Variables object.
Where,
dateStr = MAR.8.22
Note: The following screenshot shows the acceptable date formats in Astera Data Stack.
In the output window, you can see that the provided string has been converted into an acceptable DateTime value.
Example
In this example, we will pass an integer value to the function transformation object using a Variables object.
Where,
value = 123456
In the output window, you can see that our provided value has been successfully parsed, indicating that the integer has been converted into a string.
This conversion is also evident if we map the output value to a destination object. As shown below, the data type has been converted to string as well:
Example
In this example, we will pass a string value representing an unknown date format to the function transformation object using a Variables object.
Where,
str = 1978.MAR.17
In the output window, you can see that the provided value has been parsed successfully, the unknown date format has been converted into a known date format, and the Boolean value, True has been returned, indicating a successful parameter test.
Name
HexToInteger
Syntax
HexToInteger (String value)
Purpose
To convert a hex value into an integer.
Description
Returns an integer representing the specified value. Returns null if the value cannot be converted to an integer
Return Type
Integer
Parameters
value [System.String] – Value to be converted
Name
ParseDate
Syntax
ParseDate (Unknown formats, String str)
Purpose
To parse a date based on a specified format.
Description
Returns a date time value if the value was successfully parsed. Otherwise returns an error. This function successively applies specified formats and returns date time value if date is parsed using any of the specified formats.
Return Type
DateTime
Parameters
formats [Astera.Functions.DateFormats]
str [System.String] – String to be converted
Name | ToDate |
Syntax | ToDate (String dateStr) |
Purpose | To return a date converted from a string. |
Description | Converts string into a date using the current culture. Either returns the converted date or returns null if the conversion fails. |
Return Type | DateTime |
Parameters | dateStr [System.String] – A string containing date in the local culture format |
Name | ToString (Any Value) |
Syntax | ToString (Any value) |
Purpose | To convert a value into a string. |
Description | Returns the string representation of the specified value. If value is null, null is returned. |
Return Type | String |
Parameters | value [System.Object] – Value to be converted |
Name | TryParseDate |
Syntax | TryParseDate (String str, Unknown date) |
Purpose | To carry out a parameter test which checks whether a string value can be converted into a DateTime format value. |
Description | Returns true if a string value is successfully converted and parsed into a DateTime value. Otherwise returns false. |
Return Type | Boolean |
Parameters | Str [System.String] – Value to be tested Date [System.DateTime] |
Example
We have an Orders dataset with the OrderDate field.
In this example, we will pass this field to the function transformation object to get the date components.
Right-Click on the function transformation object and select Preview Output. In the output, you can see that each date from the OrderDate field has been separated in the different date components.
Example
In this example, we will pass a string value to the function transformation object using a Variables object.
Where,
value = $ 123.1234
In the output window, you can see that the provided string has been converted into a real number.
This conversion is also evident if the output value is mapped to a destination file, as shown below:
Example
We have an Orders dataset with a Freight field.
In this example we will attempt to convert the real values in this field to string values representing currency. We will map the Freight field to the data field of the function transformation object.
We will also use a Variables object to specify an acceptable Microsoft.Net format for currency.
Where,
Format = C
In the output window, you can see that the provided data from the Freight field has been converted to a string representing currency.
Example
In this example, we will pass a date value to the function transformation object using a Variables object.
Where,
value = 01/09/1994
In the output window, you can see that our provided date value has been successfully parsed, indicating that the date has been converted into a string value.
This conversion is also evident if we map the output value to a destination file. As shown below, the data type for this value has been converted to string:
Example
In this example, we will pass a value with data type set to string, to the to the function transformation object using a Variables object.
Where,
value = 03.784000
Mapping the output value to a destination object shows that the data type has been converted to decimal, hence the conversion was successful.
Name
GetDateComponents
Syntax
GetDateComponents (Date)
Purpose
To return a structure providing individual date components.
Description
Gets a structure representing individual date components.
Return Type
DateComponents
Parameters
dateTime [System.DateTime] – Date time for which components are required
Name
ToReal
Syntax
ToReal (Any value)
Purpose
To convert a value into a real number.
Description
Returns a real number representing the specified value. Returns null if the value cannot be converted to a real number.
Return Type
Real
Parameters
value [System.Object] – Value to be converted
Name
ToString
Syntax
ToString (Any data. String format)
Purpose
To convert a value into a string with a given format.
Description
Returns string representation of the specified value. Returns null if value is null or format is invalid.
Return Type
String
Parameters
Data [System.Object]
Format [System.String] – Output format of the value. This method accepts any Microsoft.Net format specification
Name
ToString (Date Value)
Syntax
ToString (Date value)
Purpose
To convert a date value into a string using default culture.
Description
Returns a string that represents the specified date. If date is null, null is returned.
Return Type
String
Parameters
value [System.DateTime] – Date to be converted
Name
ToDecimal
Syntax
ToDecimal (Any value)
Purpose
To convert a value into a decimal.
Description
Returns a decimal representing the specified value. Returns null if the value cannot be converted.
Return Type
Decimal
Parameters
value [System.Object] – Value to be converted