07-14-2022 07:10 AM
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.
Solved! Go to Solution.
07-18-2022 01:16 AM
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
07-18-2022 11:39 AM
Thank you very much for the great assistance!
It all worked.