ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Data Namespace / VersionManager Class / GetHistoricalVersion Method / GetHistoricalVersion(DateTime) Method
The time stamp of the HistoricalVersion to return.
Example

In This Topic
    GetHistoricalVersion(DateTime) Method
    In This Topic
    Gets a HistoricalVersion object with the specified moment. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public HistoricalVersion GetHistoricalVersion( 
       DateTime moment
    )
    Public Overloads Function GetHistoricalVersion( _
       ByVal moment As Date _
    ) As HistoricalVersion

    Parameters

    moment
    The time stamp of the HistoricalVersion to return.

    Return Value

    The HistoricalVersion that corresponds to moment.
    Exceptions
    ExceptionDescription
    A geodatabase-related exception has occurred.
    This method or property must be called within the lambda passed to QueuedTask.Run
    Remarks
    The moment passed into this routine has different meanings, depending on the type of versioning in use:
    • Traditional versioning - database time (local time of the database server)
    • Branch versioning - UTC time
    Example
    Switching between versions
    public void ChangeVersions(Geodatabase geodatabase, string toVersionName)
    {
      using (VersionManager versionManager = geodatabase.GetVersionManager())
      {
        VersionBaseType versionBaseType = versionManager.GetCurrentVersionBaseType();
    
        if (versionBaseType == VersionBaseType.Version)
        {
          Version fromVersion = versionManager.GetCurrentVersion();
          Version toVersion = versionManager.GetVersion(toVersionName);
    
          // Switch between versions
          MapView.Active.Map.ChangeVersion(fromVersion, toVersion);
        }
    
        if (versionBaseType == VersionBaseType.HistoricalVersion)
        {
          HistoricalVersion fromHistoricalVersion = versionManager.GetCurrentHistoricalVersion();
          HistoricalVersion toHistoricalVersion = versionManager.GetHistoricalVersion(toVersionName);
    
          // Switch between historical versions
          MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toHistoricalVersion);
        }
    
        // Switch from HistoricalVersion to Version and vice-versa 
        // MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toVersion);
        // MapView.Active.Map.ChangeVersion(fromVersion, toHistoricalVersion);
    
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also