LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build a file with date name

Solved!
Go to solution

Hi, I trying to create a TDMS file which changes his name according to date. For example. Sam finished her analysis on 12/08/21 (dd/mm/yy) at 19h25. Then, her file name must be something similar like this:

 

12-08-21-19-25.TDMS

 

It doesn't really matter if this format changes the important is creating different files with date and time.

 

It could be:

12-08-21_19-25.TDSM

1208211925.TDSM

 

Or maybe in another different way.

 

I hope you can help me. I'm a labview beginner 😀

0 Kudos
Message 1 of 7
(1,813 Views)

Hi, I trying to create a TDMS file which changes his name according to date. For example. Sam finished her analysis on 12/08/21 (dd/mm/yy) at 19h25. Then, her file name must be something similar like this:

 

12-08-21-19-25.TDMS

 

It doesn't really matter if this format changes the important is creating different files with date and time.

 

It could be:

12-08-21_19-25.TDSM

1208211925.TDSM

 

Or maybe in another different way.

 

I hope you can help me. I'm a labview beginner 😀

0 Kudos
Message 2 of 7
(1,775 Views)

You can used Format into String on the timestamp and look at the special format codes for date and time.

 

If I were you, I'd consider doing it in a YYMMDD rather than day first like yyou have.  That way when you sort the file names alphabetically, you'll be sorting them by date as well with the oldest files first and newest files last.

 

I don't have LabVIEW in front of me to check, but the format string would be something like %<%yymmdd_HHMMSS.tdms>T

Message 3 of 7
(1,791 Views)
Solution
Accepted by topic author JoshX10

 

Time and Date.png

Change d, m,y as needed.

Message 4 of 7
(1,782 Views)

I had a colleague who embedded the Date in the File Name -- it drove me crazy!  All those characters required to represent the file's name, and the only information it carries is when the file was created, not what "Experiment" it was, what "Test #" it represents, the "ID of the Subject", something that might be relevant to the data contained in the file.

 

There are two ways to get the date of the file without putting it in the filename.  First, simply write it as an element in the file (this works especially well for Text files, XML files, or other things where "Date" might be a "natural" data element).  This is what you should do if the date/time are really important, otherwise you are going to have to "deduce" the date/time by parsing the file name, which can get a bit messy.

 

Second, when you save a file, Windows saves its Creation Date as part of the Directory Entry.  Note that File Dates are easily sorted by Window's File Explorer if you just want to "find the oldest" (or newest).

 

So think carefully when you are deciding on a File-Naming convention.

 

Bob Schor 17:30 15 August 2021

0 Kudos
Message 5 of 7
(1,739 Views)

what does "%s" means when you use format into string?

0 Kudos
Message 6 of 7
(1,715 Views)

It's the placeholder for a string.

 

But Bonkerz example is a little bit of a Rube Goldberg because the Format into string function will take the timestamp direction when you use the timestamp format code.

Message 7 of 7
(1,708 Views)