Trunc(Object, Object) Method
Truncates the specified numeric or timestamp to the next lower unit.
Definition
Namespace: GHost.GSharp.PI.ACE
Assembly: GHost.GSharp.PI.ACE (in GHost.GSharp.PI.ACE.dll) Version: 1.2.44.3 (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.
- Object
- The size of the unit to truncate to. If x is a number, unit must be a number. If x is a timestamp, unit must be a time period.
Return Value
Object
Possible return values are:
- Value of type Double truncated to next lower integer for numeric value.
- Value of type Date truncated to next lower second for timestamp value.
Remarks
The largest value smaller than value which is an integer multiple of unit is returned. Returns Nothing and raises an error if value is an invalid time string or if unit is of wrong type.
Example
C#
Dim myDouble As Double
Dim myDate As Date
myDouble = Trunc(22.5, 5) 'Returns 20
myDate = Trunc(DateTime.Today.AddSeconds(7.5),3) 'Returns DateTime.Today.AddSeconds(6)
Exceptions
| ArgumentException |
See Also
Reference
PIACEBIFunctions Class
Trunc Overload
GHost.GSharp.PI.ACE Namespace