DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

convert time channel format

Solved!
Go to solution

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

0 Kudos
Message 1 of 4
(7,953 Views)

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

Function: TTR

Converts time format text into the number of seconds since 01/01/0000.

ReturnValue = TTR(String [,Format])

Input Parameters

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.

Return Parameters

ReturnValue Returns a Double value.

Examples

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

 

Otmar D. Foehner
Message 2 of 4
(7,951 Views)
Solution
Accepted by topic author Steve Koza

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

Message 3 of 4
(7,927 Views)

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

0 Kudos
Message 4 of 4
(7,911 Views)