DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

support of TimeStamp in function datediff

Solved!
Go to solution

Hello,

 

I run the same Script in Diadem Version 2012 and 2014. The Script include the function DateDiff() of 2 channels which are identified as a date-channel. In the Version 2012 the Script run without errors and in the Version 2014 the Script throw out a error because of overflow. In the Version 2014 it seems to be that the function DateDiff()  does not support the TimeStamp, because if you convert the date into a String it works.

Is it possibly that in the new Version 2014 of Diadem the function DateDiff()  does not support the format of TimeStamp?

For me it would be interesting because of the performance of huge data sets.

 

Thanks in advance,

Thomas

0 Kudos
Message 1 of 5
(5,756 Views)

Hi Thomas,

 

DateDiff() is a VBScript function that compares two scalar datetime variables.  It does not and can not natively compare all the values of two datetime channels in the Data Portal.  Were you by chance using that function in the DIAdem Calculator?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(5,743 Views)

Hello Brad,

 

sorry I have not express myself correctly. For sure the function DateDiff() only compare two variables and not the channel in all.

I have use the function in the VBS-Script and compare all rows of a channel particular, that means every single cell. I do not think that there is a chance of using the calculator, because the function is part of a bigger function which compare different cells in a channel.

(for both examples the channels date_time_stator and date_time_rotor are channels of a date)

Here a simple example of the script is not working in Diadem 2014:

 

Dim date_time_1, date_time_2, date_diff  

Set date_time_1 = Data.Root.ChannelGroups("RACF").Channels("date_time_stator")

Set date_time_2 = Data.Root.ChannelGroups("RACF").Channels("date_time_rotor")

date_diff = DateDiff("s",date_time_1(1),date_time_2(1))

 

Here a simple example of the script is working in Diadem 2014:

 

Dim date_time_1, date_time_2, date_diff

Dim date_time_1_new, date_time_2_new

Set date_time_1 = Data.Root.ChannelGroups("RACF").Channels("date_time_stator")

Set date_time_2 = Data.Root.ChannelGroups("RACF").Channels("date_time_rotor")

date_time_1_new = str(date_time_1(1),"#YYYY-MM-DD hh:nn:ss")

date_time_2_new = str(date_time_2(1),"#YYYY-MM-DD hh:nn:ss")

date_diff = DateDiff("s",date_time_1_new,date_time_2_new)

 

It shows if you change the date into a string it works, otherwise the Error: "overflow" occurs.

The curios thing the same VBS-Script is working in Diadem 2012 and is working in older scripts very well!

Do you have a idea why?

 

best regards,

Thomas

0 Kudos
Message 3 of 5
(5,714 Views)
Solution
Accepted by topic author ThomasBergk

Hi Thomas,

 

The variable subtype that is returned from a datetime channels has changed a bit through the DIAdem versions.  Nowadays you have 3 choices for how to retrieve a particular row's value from a datetime channel:

 

Set TimeChannel = Data.Root.ChannelGroups(1).Channels(1)
VbsDateTime = TimeChannel.Values(1)
DIA_Seconds = TimeChannel.dValues(1)
Set TimeObj = TimeChannel.oValues(1)

If you just want to compare the difference between two datetime values in seconds, I'd use the middle option above. 

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 5
(5,695 Views)

Hello Brad,

 

thank you for your answer.

Thats a good option.

 

kind regards,

Thomas

0 Kudos
Message 5 of 5
(5,656 Views)