Trunc(Object, Object) Method
Truncates the specified numeric or timestamp to the next lower unit.
Definition
Namespace: GHost.GSharp.Analytics.AF
Assembly: GHost.GSharp.Analytics.AF (in GHost.GSharp.Analytics.AF.dll) Version: 1.2.0.0 (1.2.44.3)
C#
public static Object Trunc(
Object value,
Object unit
)
VB
Public Shared Function Trunc (
value As Object,
unit As Object
) As Object
Parameters
- Object
- Numeric or timestamp value that needs to be truncated.
For timestamps, this can be a DateTime object, AFTime object, or valid string that can be converted to either of these objects.
- Object
- The size of the unit to truncate to. If value is a number, unit must be a number. If value is a timestamp, unit must be a time period.
Return Value
Object
Possible return values are:
- Value of type Double truncated to next lower unit for numeric value.
- Value of type DateTime truncated to next lower unit for timestamp value.
Remarks
Throws an exception if value is an invalid time string.
Example
C#
double dblResult;
DateTime dtResult;
dblResult = Trunc(22.5, 5); //Returns 20
dtResult = Trunc(DateTime.Today.AddSeconds(7.5),3); //Returns DateTime.Today.AddSeconds(6)
Exceptions
| ArgumentException | Returns an ArgumentException if the passed in value is not a valid numeric type or timestamp object. |
See Also
Reference
FunctionLibrary Class
Trunc Overload
GHost.GSharp.Analytics.AF Namespace