LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format specifier combination for time stamps

Solved!
Go to solution

Hi,

I am trying to find a format specifier combination for time stamps which will be written to file. In using the file I need to see the date and when processing the data I need all the decimal digits of the time stamp. I have made a small vi incorporating the timestamp source from my main program to play around with but cannot get the correct format specifier. Using this format specifier "%H%M%S%8u" on the Format Date/time String VI it is outputting the correct number of decimal places but the other part is not recognisable as the date minutes seconds. ie 140404.51230382.

I put that format Date/Time String vi in my test vi just to test a different way of doing it but what I really want to do is carry on with the Format into string vi. But editing the Format into String vi format specifier didnt seem to work.

 

Any suggestions gratefully received

 

0 Kudos
Message 1 of 12
(501 Views)

@EdHarris wrote: Using this format specifier "%H%M%S%8u" on the Format Date/time String VI it is outputting the correct number of decimal places but the other part is not recognisable as the date minutes seconds. ie 140404.51230382.

What do you mean by “not recognisable”?
According to your specifier, the “14” represents the hours (in UTC), “04” the minutes, and the next “04” the seconds; the rest is the fractional part.
What result are you expecting?

 

0 Kudos
Message 2 of 12
(462 Views)

Do you simply want separators? Use "%H.%M.%S%8u" or "%H:%M:%S%8u".

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 3 of 12
(437 Views)

 


@Andrey_Dmitriev wrote:

@EdHarris wrote: Using this format specifier "%H%M%S%8u" on the Format Date/time String VI it is outputting the correct number of decimal places but the other part is not recognisable as the date minutes seconds. ie 140404.51230382.

What do you mean by “not recognisable”?
According to your specifier, the “14” represents the hours (in UTC), “04” the minutes, and the next “04” the seconds; the rest is the fractional part.
What result are you expecting?

 


You are right, it is the correct time for my location. My next problem is how to add the date?

Looks like I will only be able to do this by using multiple Format Date/Time String vis because if I try adding any more % specifiers in the  Format into string VI it says too many format specifiers. Is there away round that?

0 Kudos
Message 4 of 12
(420 Views)
Solution
Accepted by topic author EdHarris

@EdHarris wrote:

You are right, it is the correct time for my location. My next problem is how to add the date?


Exactly the same way:

snp.png

Refer to the help topic: https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/format-date-time-string.html

 

Or something like this if you prefer:

snp3.png

The "%,;" can specify separator for the fractional part - "." or ",".

Message 5 of 12
(408 Views)

With my exposure to Python, I have grown fond of ISO 8601 datetime strings.

Epoch Date & Time Toolkit for LabVIEW - Download - VIPM by JKI library provides a VI to format ISO8601 strings

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution
Message 6 of 12
(371 Views)

Thats really helpful.

I also found %c%8u produces this format: 03/08/2026 13:55:18.44514274

But I had to rewrite my code like this because couldnt make the Format into String VI do anything useful.

timetest2.png

0 Kudos
Message 7 of 12
(352 Views)

Hi Ed,

 


@EdHarris wrote:

But I had to rewrite my code like this because couldnt make the Format into String VI do anything useful. 


Why shouldn't FormatIntoString doesn't format timestamps correctly? Did you read the help for the format codes?

When using %c format code you need to keep in mind the result can differ between computers/account settings…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 12
(340 Views)

@GerdW wrote:

Hi Ed,

 


@EdHarris wrote:

But I had to rewrite my code like this because couldnt make the Format into String VI do anything useful. 


Why shouldn't FormatIntoString doesn't format timestamps correctly? Did you read the help for the format codes?

When using %c format code you need to keep in mind the result can differ between computers/account settings…


If you have multiple inputs, I couldnt find any way of making them be treated separately. Format into stringVI just thinks every % in the box applies to a separate input and threw an error for too many percent codes.  You see there are multiple % codes in each format specifier for each input.

0 Kudos
Message 9 of 12
(327 Views)

Hi Ed,

 


@EdHarris wrote:
If you have multiple inputs, I couldnt find any way of making them be treated separately. Format into stringVI just thinks every % in the box applies to a separate input and threw an error for too many percent codes.
You see there are multiple % codes in each format specifier for each input.

There are already two %-codes for each value in the last example.

 

Next example:

3 input values for FormatIntoString, formatted 3 times as timestamp, with different (number of) formatting codes per entry…

 


@EdHarris wrote:
Format into stringVI just thinks every % in the box applies to a separate input

Yes, sure. But if you read the help for those formatting codes you should have noticed the "Variable Order" format code %$ that allows using the same input several times…

Did you read the help?

3rd example:

2 input values formatted as 3 items…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
Message 10 of 12
(312 Views)