LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Date/Time String Seconds

My application records data being acquired from the NI instruments into a file. To make each data file name unique, I decided to use a date and time stamp as part of the file name. My application uses the “Get Date/Time In Seconds” to obtain the date and time when the application started to execute. I wired the output of that VI into “Format Date/Time String” as the time stamp. I wired in the string “NI %04Y-%02m-%02d %02H-%02M-%02S.dat” as the time format string (%c). The resulting file name will look like “NI 2006-01-03 05-02-07.dat”. This worked correctly in LabVIEW version 7.1. In LabVIEW version 8.0, this does not work. The seconds format field, “%02S”, returns a blank string. I also determined that the seconds format field, “%2S”, returns a blank string. If I removed the width and zero pad syntax elements such that I only have “%S”, the VI returns a 2 character string such as “02”, “34”, etc. and works correctly. The other fields, Y,m,d,H, and M, accept the width and zero pad syntax elements. There is some inconsistency in how the “Format Date/Time String” behaves.

 

Since it appears that the format string will insert leading zeros, I will change my application to use “%S”, “%m”, %d”, etc.

 

 

I have also noted the following odd behavior:

 

Does not recognize syntax elements (I would think it would return the entire “%02r” rather than just the “r”

 

“%02r”    returns   r

“%02D”  returns    “”   (empty string)

 

Do not know where this comes from. It is not in LabVIEW Help under Format Codes for the Time Format String.

 

“%02z”  returns   -06:00:00
0 Kudos
Message 1 of 2
(3,935 Views)
I wouldn't agree with the inconsistency statement. In LabVIEW 7.1 you also get the zero-prepended values if you use “%S”, “%m”, %d”, etc. In fact, the documentation doesn't say anything about needing to use %02S, so why are you using the "02" characters?

Message Edited by smercurio_fc on 02-01-2006 02:19 PM

0 Kudos
Message 2 of 2
(3,927 Views)