Skip to main content

mes.fnGetRunTimesAndCounts

Description

Returns runtime, downtime, and counter totals for a given asset within a time range.

Syntax

mes.fnGetRunTimesAndCounts(@assetId, @startDate, @endDate)

Parameters:
  • @assetId (int): Asset Id
  • @startDate (datetime): Start of the time range
  • @endDate (datetime): End of the time range

  • Returns:
    Returns a table with columns:
  • runtimeSecs (int): Running time in seconds
  • unplannedDowntimeSecs (int): Unplanned downtime in seconds
  • plannedDowntimeSecs (int): Planned downtime in seconds
  • rawInfeedCount (float): Total infeed count
  • rawOutfeedCount (float): Total outfeed count
  • rawWasteCount (float): Total waste count
  • Code Example

    -- Get production runtime and counts summary
    SELECT *
    FROM mes.fnGetRunTimesAndCounts(2076, '2025-07-01T00:00:00', '2025-07-30T23:59:59');