Convert To Df Time?


BeeHay

Recommended Posts

Hello again AzeoTech!

Just a quick question, is there a FormatDateTime function to format a variables time into DF time?

Also, having a tough one with my "time lookup" stuff...


Variable1[FormatDateTime(%H:%M:%S, Variable2.Time[0])]
[/CODE]

Using the above code converts Variabe2's time into a readable number, but then subsets my Variable1 with the first value in Variable2's time...

Say the time is 12:05:01, my Variable1 is then subset to [12] instead of looking at the time of Variable2 and showing the value of Variable1 at Variable2's time...I need the value at 12:05:03 instead of subsetting [12]

Any advice would be great!

Link to comment
Share on other sites

In order to subset by time you have to have time in DF format, namely seconds since 1970 (also Unix and windows format I should add). FormatDateTime gives you human readable format. In your example, you just want to subset on variable2.time[0] since that's already in DF time. Note, however, that the subset will only work if the there is a data point in variable1 with the exact same time stamp as variable2.time[0]. Its usually better then to use a range, even if its a small one, say: [variable2.time[0], variable2.time[0] - 0.1] DF records time to the microsecond, so the range can catch small discrepencies. If more than one point fit in that range, you'll get an array, which you can then just subset by index [0].

And to answer what I believe is your first question, the StrToTime() function will take human readable time (12:05:01) and convert into DAQFactory time. Its in the user's guide in the Expressions chapter, reference, time functions.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.