LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write Date/Time property of tdms file

Solved!
Go to solution

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.

0 Kudos
Message 1 of 6
(8,801 Views)
Solution
Accepted by Marg_SZ

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);

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(8,781 Views)

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.

0 Kudos
Message 3 of 6
(8,768 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 6
(8,750 Views)

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:

 

DateTime TDMS

 

 

Hope it helps!

 

Ben

Message 5 of 6
(8,584 Views)

Yeah....  I got it right.  Thank you for help, Ben.

 

 

0 Kudos
Message 6 of 6
(8,574 Views)