DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script for changing dates in timestamps

Solved!
Go to solution

Dear all,

 

 

I need some help with a task that I simply cannot get my head around.

 

What I need is a simple script, which changes the date in all timestamps in a file, loaded into DIAdem.

 

Example:

I open a TDMS file into DIAdem manually.

The file contains one day of measurement data, where the first column is a DateTime column holding the timestamps.

A timestamp could look like this: 

07/07/2022 00:00:02.

I need a scrip to change the date part of every timestamp, so the above example then looks like this:

01/01/2000 00:00:02

 

Can someone point me in the right direction?

Any help is much appreciated.

 

 

0 Kudos
Message 1 of 3
(1,008 Views)
Solution
Accepted by topic author PureNI

Hi PureNI,

 

here is a script example:

dim oTimeChn, oFirstTimeVal, oTargetDate, dTimeDiff
' variable for time channel
set oTimeChn  = Data.Root.ChannelGroups(1).Channels("MyTime")
' get first value of the time channel as date/time data type
set oFirstTimeVal = oTimeChn.oValues(1)
' create a time variable as date/time data type
set oTargetDate = CreateTime(2000, 1, 1, 0, 0 , 2)
' calculate the difference in seconds from year 0
dTimeDiff = oFirstTimeVal.SecondsFrom0000 - oTargetDate.SecondsFrom0000
' calculate the new channel (or implace)
call ChnOffset(oTimeChn, "/Offset", -dTimeDiff, "free offset")
' calculate implace
'call ChnOffset(oTimeChn, oTimeChn, -dTimeDiff, "free offset")

 

Greetings

Walter

0 Kudos
Message 2 of 3
(980 Views)

Thank you very much for the great assistance!

It all worked.

0 Kudos
Message 3 of 3
(969 Views)