LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to input the words Date and Time into the File Format String?

Solved!
Go to solution

So right now I have a VI in which when you click Save it saves the current state of the Front Panel as a Jpeg. That all works fine. But I wanted to automatically save the file as the current date by using -%y-%d-%H-%M-%S. That also works fine. The only problem? When saved the name of the file looks like a bunch of random numbers.

Ex. 2017-08-28-12-54-19. 

 

Technically this is fine. It's correct. But it looks like crap. Is there a way I can modify the File Format String so that the final file reads "Date: 2017-08-28 Time: 12-54-19"?

0 Kudos
Message 1 of 18
(4,137 Views)

Well you probably don't want (or aren't allowed) to have colons in the filename. But there is a function called "format into string". For the format string you can use any words then "%s" as a placeholder. Since your date has 10 characters always, you can just split your string after 10 characters and use "Date %s Time %s" with the first input being your date and the second being time.

 

Personally, when I collect data during the test it often looks like "20170828_143518_Voltages" for example, and it is easy for me to know the first 8 characters are the date and the next 6 after the underscore are time.

0 Kudos
Message 2 of 18
(4,127 Views)
Solution
Accepted by topic author ShogunOrta

@ShogunOrta wrote:

Ex. 2017-08-28-12-54-19


I typically go with something more like "2017-08-28 12-54-19".  That space makes a good separation between the Date and the Time.  But to answer your question:


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 18
(4,113 Views)

Is that function you used there a Time Stamp function?

0 Kudos
Message 4 of 18
(4,096 Views)

Hey, thanks for that. But....you wouldn't know how to insert a ":" so that the time looks like 14:32:12, rather than 14-32-12?

0 Kudos
Message 5 of 18
(4,091 Views)

Hi Orta,

 

the colon is one of those chars not allowed in filenames...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 18
(4,087 Views)
Solution
Accepted by topic author ShogunOrta

While the colon ":" is not permitted, oddly enough, the semi-colon ";" is permitted as part of a filename.  Just replace the "-" after the %H and %M with the semicolon ";" for a close visual approximation.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 7 of 18
(4,081 Views)

Yep, that'll work. But I've been looking around the net and have found several examples of Date formatting codes that supposedly give you the current time with colons included. I've tried %T, %t, %X, %x, %Z, %z, and on and on, but nothing works. Does Labview actually have anything like that? Maybe I'm just implementing it wrong. 

0 Kudos
Message 8 of 18
(4,074 Views)

The default (unwired) is %c. If you want just the time in 24-hour format you can use "%H:%M:%S"

0 Kudos
Message 9 of 18
(4,061 Views)

But in "%H:%M:%S", my Labview doesn't seem to accept the colons. I have 2015 though.

0 Kudos
Message 10 of 18
(4,056 Views)