Skip navigation
All Places > All Things PI - Ask, Discuss, Connect > Blog > Author: fzhang

A customer stopped by the PI ProcessBook pod on Wednesday asking how to grab just the M/DD part of a timestamp from a Value symbol with VBA. Here's a quick example when you have a value symbol on your display called Value1.


Sub Test()


Debug.Print showMonthAndDayOnly(Value1)


End Sub


'takes a value symbol and returns M/DD string for the timestamp

Function showMonthAndDayOnly(valueSymbol As Value) As String


Dim vValue As Variant

Dim vTime As Variant

Dim vStatus As Variant


vValue = valueSymbol.GetValue(vTime, vStatus)


Dim sDate As String

Dim i As Integer


'finds location of 2nd "/" in the timestamp's date

i = InStr(1, vTime, "/")

i = InStr(i + 1, vTime, "/")


showMonthAndDayOnly = Mid(vTime, 1, i - 1)


End Function

Filter Blog

By date: By tag: