Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Powershell

ConvertFromAFRelativeTime Class

  • Last UpdatedDec 15, 2025
  • 3 minute read
ConvertFromAFRelativeTime Class

Converts a PI Time string into a DateTime

The ConvertFrom-AFRelativeTime cmdlet will convert a relative time into a DateTime and optionally translate it into local or UTC time.

By default the returned timestamp will not have a timezone associated with it.

Inheritance Hierarchy

SystemObject
  InternalCommand
    Cmdlet
      PSCmdlet
        OSIsoft.PowerShellOSICmdletBase
          OSIsoft.PowerShellConvertFromAFRelativeTime

Namespace:  OSIsoft.PowerShell
Assembly:  OSIsoft.PowerShell (in OSIsoft.PowerShell.dll) Version: 2.2.3.0 (2.2.3.952)

Syntax

[CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess = true)]
[AliasAttribute(new string[] { ... })]
public class ConvertFromAFRelativeTime : OSICmdletBase
<CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess := true)>
<AliasAttribute(New String() { ... })>
Public Class ConvertFromAFRelativeTime
	Inherits OSICmdletBase

Dim instance As ConvertFromAFRelativeTime
[CmdletAttribute(L"ConvertFrom", L"AFRelativeTime", SupportsShouldProcess = true)]
[AliasAttribute(__gc new array<String^>^ { ... })]
public ref class ConvertFromAFRelativeTime : public OSICmdletBase
[<CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess = true)>]
[<AliasAttribute(new string[] { ... })>]
type ConvertFromAFRelativeTime =  
    class
        inherit OSICmdletBase
    end

The ConvertFromAFRelativeTime type exposes the following members.

Constructors

  NameDescription
Public method
ConvertFromAFRelativeTime

Properties

  NameDescription
Public property
LocalTime

Force the returned timestamp to be in local time

Public property
RelativeTime

The PI Time string to convert to DateTime. For example:

"*" or "*-2h" or "*+1d"

Public property
UtcTime

Force the returned timestamp to be in UTC time

Examples

ConvertFrom-AFRelativeTime -RelativeTime "*"

This example will return a System.DateTime for the current time in UTC.

Examples

ConvertFrom-AFRelativeTime -RelativeTime "*-2h"

This example will return a System.DateTime for "two hours ago" in UTC.

Examples

ConvertFrom-AFRelativeTime -RelativeTime "T+8h -LocalTime"

This example will return a System.DateTime for "today at 8am" in the local machine's time zone.

Examples

Get-PIValue -PointName "Sinusoid" -Time (ConvertFrom-AFRelativeTime -RelativeTime "*") -ArchiveMode Interpolated -Connection $con

This example uses the ConvertFrom-AFRelativeTime cmdlet to get the interpolated value of tag "sinusoid" at the current time.

See Also

TitleResults for “How to create a CRG?”Also Available in