10-05-2009 03:01 PM
I have a channel saved in a MM/DD/YYYY HH:MM:SS.XXXX format, and I would like to convert it back into a numeric representation. I've read on the forums that it will be the number of seconds since 0 AD, which I'm fine with. I just need to convert the entire channel back into the number of seconds.
I'm trying to process data with a funky, random sampling rate, and I'm trying to use the ChnMapLinCalc function to redistribute the data over a sampling rate that makes sense.
Thanks!
Steve
Solved! Go to Solution.
10-05-2009 05:34 PM
Steve Koza wrote:I have a channel saved in a MM/DD/YYYY HH:MM:SS.XXXX format, and I would like to convert it back into a numeric representation. I've read on the forums that it will be the number of seconds since 0 AD, which I'm fine with. I just need to convert the entire channel back into the number of seconds.
Steve,
Check out the TTR and RTT functions in the help system, they do what you want (both ways, from time to numeric and from numeric to time).
Function: TTR
Converts time format text into the number of seconds since 01/01/0000.
ReturnValue = TTR(String [,Format])
String | Specifies a text or a variable that contains the date. The text must not contain written or abbreviated weekdays, months, or calendar weeks. |
[Format] | Specifies the time format for the text according to the format instructions.
If you do not specify a time format, DIAdem applies the default format specified under Settings»Options»General. |
ReturnValue | Returns a Double value. |
The following example converts a date into the number of seconds that have elapsed since 01/01/0000.
Dim dMyResult dMyResult = TTR("24.12.1024","dd.mm.yyyy") 'dMyResult = 3.2345136E+10
Hope that helps,
Otmar
10-06-2009 10:02 AM
Hi Steve,
If the data channel you're talking about is already loaded in the Data Portal, and if it already has a clock symbol to the left of it in the Data Portal, then all you need to do is change the display of the channel values. DIAdem date/time channels are regular DBL channels that have a display property set to show the data differently in DIAdem (as a date/time string). So you don't need to convert anything. Look for the property "Display format" in the Data Portal and change it from "Time" to "Numeric". You may have to force a refresh by clicking in VIEW, but that channel should immediately display as DBL values.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-07-2009 06:59 AM
Thank you both for your replies. I had tried using the TTR function to loop over the channels, but had trouble getting the syntax right. The "Display Format" solution worked great though. I just used the ChnPropValSet function on the time channel, and everything was good. Thanks for the quick replies!
Steve