YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

How to display the millisecond part of a PI tag timestamp in a VBA code Options · View
gillesmpem
#1 Posted : Sunday, August 22, 2010 7:29:04 PM
Rank: Newbie
Groups: Member

Joined: 8/22/2010
Posts: 2
Location: usa
When I create a trend in OSISOFT PI, I can see in the details window Tag values and Timestamps, and the timestamps are shown with the millisecond part. Like this: 08/23/2010 8:12:24.4563 PM. Now, when I try to write a VBA module to get the same Tag data so that I can print them in a Text file or a database (or whatever else I wanna do with them), surprisingly I can't display the millisecond part of the timestamps.
Here is a line od a code where I am printing timestamps:

Print #1, CStr(pv.TimeStamp.LocalDate)

where pv is a PIVALUE object.

Anyone knows I to solve this problem? I know for sure this is possible, because the Details windows shows the millisecond part.
Thanks for your help
Sponsor  
 

OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System.
We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ  or contact OSIsoft vCampus for more details.
RJK Solutions
#2 Posted : Sunday, August 22, 2010 9:03:43 PM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Hello,

Welcome to the forum.

To my knowledge, you can't display milliseconds for a Date/Time data type in VBA. Here is a quote from the web:
Quote:

The Date/Time data type in VBA isn't capable of storing milliseconds
accurately, and even if it could, you can't display it. It's an 8 byte
floating point number, where the integer part represents date as the number
of days relative to 30 Dec, 1899, and the decimal part represents time as a
fraction of a day.


The details pane can display the milliseconds because it is a .Net addin using a .Net Date/Time data type that has the precision to hold milliseconds.

Principal Consultant
Real-Time Data Management @ Wipro Technologies
gillesmpem
#3 Posted : Monday, August 23, 2010 12:22:41 AM
Rank: Newbie
Groups: Member

Joined: 8/22/2010
Posts: 2
Location: usa
If VBA cannot display the milliseconds, does PI support .NET codes and can I have such code ?
RJK Solutions
#4 Posted : Monday, August 23, 2010 8:06:39 AM
Rank: Administration

Groups: Administration

Joined: 6/20/2008
Posts: 612
Location: Cheshire, United Kingdom.
Indeed you can, you just need to create a .Net add-in for ProcessBook. There are downloadable examples on vCampus.

It depends on your overall objective as with a .Net add-in you can apply logic to all displays instead of just the one.
Principal Consultant
Real-Time Data Management @ Wipro Technologies
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.