LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to timestamp

Solved!
Go to solution

Hi,

I've been searching for a while now and still don't have an answer.

I try to convert from a string to a timestamp value.

I can't find the correct expression to retrieve the seconds and miliseconds.

I have tried %S,%u or even %3u. still not work.

Any idea.

 

String to timestamp.png

NTA_LabView_certified_Developper.jpg
0 Kudos
Message 1 of 9
(7,304 Views)

I just played around a bit and changed the comma separator between your seconds and fractional seconds to a point instead of a comma, then used the following format string:

 

%<%y-%m-%d %H.%M.%S%3u>T

 

Note I did not specify a separator between the %s and %3u. I scanned the 172 ms portion successfully.

 

I saved the vi and exited LabVIEW, then configured my regional settings for France. I opened the same VI and the scan string failed for the decimal point but worked when I reverted the string to your original ',' separator between the whole and fractional seconds.

 

I'm guessing that LabVIEW is using your localization settings to determine the <%<digits>u> portion and that your settings in your OS are for a decimal separator of "."

 

Yet another example of LabVIEW's quirks with respect to dealing with locale. Smiley Sad


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 2 of 9
(7,290 Views)
Solution
Accepted by toto26

Hello,

 

try the format string (no quotes) "%<%y-%m-%d %H.%M.%S.%3u>T".

In your example, you had an "%" too many behind the "M", also I replaced the comma with another period.

 

Greetings! 

0 Kudos
Message 3 of 9
(7,289 Views)

Hi there toto,

 

try dropping the comma-symbol between the seconds and milliseconds and it should be fine. (%<%y-%m-%d %H.%M.%S%3u>T).

 

Cheers,

 

Cerati

0 Kudos
Message 4 of 9
(7,288 Views)

Hi

Thank to all of you.

Unfortunately, it's not so easy. I use the French regional settings, so the separator is a coma, I don't have the choice (the string come from a filename)

I've already tried to change the coma with a dot, it has no effect on the result.

In fact, the following works, but as you can notice, it's impossible to use : in a filename.

String to timestamp2.png

Regards

 

NTA_LabView_certified_Developper.jpg
0 Kudos
Message 5 of 9
(7,263 Views)

The Scan from String function has an optional setting to set Localization Codes.

 

The Scan time stamp appears to ignore this setting when evaluating the %<digits>u fractional portion of a timestamp and always uses the OS locale settings. Tested in LabVIEW 8.6 and 2010

 

I would consider this is a bug.


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 6 of 9
(7,257 Views)

Thank you wimba,

I did not noticed that I had too many %

It works

Regards

NTA_LabView_certified_Developper.jpg
0 Kudos
Message 7 of 9
(7,252 Views)

The inability to use a colon ":" in a filename is normally an OS limitation. We typically use a space or underscore when naming a file that contains a date and time within the filename itself.

 

example:

 

DNX1U FVT[FC52055531][2012 12 19][13 12 40][P].xml

 

The brackets are used to identify the logical parts of the name TEST[SERIAL NUMBER][DATE][TIME][PASS or FAIL]

 

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 8 of 9
(7,248 Views)

You are correct that there is a bug with the conversion of string values to timestamps in reference to the localization code. R&D is aware of this issue as stated in this forum post: http://forums.ni.com/t5/LabVIEW/Can-t-change-decimal-sign-in-timestamp-BUG/m-p/647863  and a Corrective Action Request (CAR) has been filed. The number for that CAR is  45360. The Developers intend to correct this issue and it will be implemented in a future major revision of LabVIEW.

 

Larry H.

Applications Engineer
National Instruments
0 Kudos
Message 9 of 9
(7,218 Views)