06-09-2014 03:29 PM
On the root page of the tdms file, there is a built-in property called "Date/Time" in the first row.
I would like to use it to save the time stamp when the tdms file is created. But in the help file,
I only find the following property constant. So, how can I write to the "Date/Time" property field?
Property | Constant | Data Type |
Name | TDMS_FILE_NAME | String (char *) |
Description | TDMS_FILE_DESCRIPTION | String (char *) |
Title | TDMS_FILE_TITLE | String (char *) |
Author | TDMS_FILE_AUTHOR | String (char *) |
Thanks for any idea or suggestion.
Solved! Go to Solution.
06-10-2014 02:18 AM
Not sure if this is exactly what you want, but have you tried this?
CVIAbsoluteTime CVItime, *t = NULL; TDMSFileHandle deH = 0; // Create TDMS file and set some properties errChk (TDMS_CreateFileEx (file, TDMS_Streaming2_0, TDMS_ByteOrderNative, 0,"example.tdm", "someText", "title", "author", &deH)); // ... GetCurrentCVIAbsoluteTime (&CVItime); errChk (TDMS_SetFileProperty (deH, "Date/Time", TDMS_Timestamp, CVItime));
// ...
// Save and close file
errChk (TDMS_SaveFile (deH));
TDMS_CloseFile (deH);
06-10-2014 03:13 PM
Thank you for replying.
I tried your suggestion and it did save a property field "Date_Time" with date time value even though you passed "Date/Time".
I don't know how to write to the built-in property "Date/Time". NI engineers designed this property field but did not tell user how to use it.
Appreciate your help.
06-11-2014 04:30 AM
You're right, I noted this when I wrote the code I posted here a few years ago.
I can add that all non-alphabetic characters (including spaces) are translated by TDMS functions to unserscores: for example, if I write a file property named "Supply (V)" it will be saved as "Supply__V_".
This is not declared anywhere in the documentation for TDMS library functions but in my opinion it should be.
07-10-2014 07:33 AM
Hi, I had also same question.
Date/Time value on header of the TDMS file is written "naming" it DateTime; without the slash and no space between both words. I find it a little bit weird but it works.
At least, value is read correctly on Excel using the TDMS add in and also using the TDMS - File viewer.vi
Small example:
Hope it helps!
Ben
07-10-2014 01:42 PM
Yeah.... I got it right. Thank you for help, Ben.