LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Time Stamp will milli seconds from string time stamp format

Hi Guys,

 

I am trying to get the time stamp with milli seconds value from string format time data,

 

Attached the snippet (Get milli seconds to Time stamp)I  tried.

Attached Sub VI Convert string to time stamp

 

When run,I am not getting the time string indicator with milli seconds value even though the format have <%2u> .

 

please guide me on this.

 

 ..AND Finally i will be converting the date and time string output to time stamp data type

 

 

0 Kudos
Message 1 of 10
(4,757 Views)

Try using "%<%H:%M:%S%.2u %p>T".  The underscore seems to cause issues for me, not enough time to mess around with it from there.  Notice the period with the %.2u.  That was the part you were missing.


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 2 of 10
(4,726 Views)

Hi 

 

 

if we get time string indicator in milli second,then we can make into time satmp by appending the date and time string.

 

But time string doesnt seems to give its out in milli seconds.

 

0 Kudos
Message 3 of 10
(4,718 Views)

That function will not return anything but full seconds. To get milliseconds, use 'Format Date/Time String' with the same time format string you used when creating the time stamp.



CLA
www.dvel.se
0 Kudos
Message 4 of 10
(4,712 Views)

The problem is that the Get Date/Time String function does not return partial seconds.

 

There are no partial seconds to be parsed out in your sub-vi.

 

The AM/PM portion infers that the hours would be 1-12, so you would want to scan using %I instead of %H

 

Also, your sample string is missing the year. You would use %Y for a 4 digit year, %y for a 2 digit year.

 

Try using this format string:

 

%<%I:%M:%S%2u %p_%d-%b-%Y>T

 

Get Milli seconds to Time stamp.png

 

 


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

Message 5 of 10
(4,705 Views)

Make a minor change to Convert_String_to_TimeStamp.  Assume that your Date/Time String input has the format shown on the Front Panel.  In Scan From String, change the format string to %d/%d?%d %d:%d:%d.%d %s, i.e. add an extra element for milliseconds.  You can't immediately use it, as the cluster doesn't support it.  However, a TimeStamp is simply a representation of seconds since 1 Jan 1904.  Wire the TimeStamp output to an Add function, and in the other input to the Add, wire the output of a Divide function, milliseconds (from your Scan from String) divided by 1000.  You will be pleased with the result.

 

Bob Schor

Message 6 of 10
(4,691 Views)

Hi Bob,

 

 

Did the changes and now it gives the milliseconds.

 

Attached the solution png.

 

Thanks to all

0 Kudos
Message 7 of 10
(4,627 Views)

You do realize you could have just used a single Scan From String to get the timestamp, right?


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 8 of 10
(4,611 Views)

Not to be too picky, but if the initial time is 8:05:35.218 PM, Crossrulz's returned time is twelve hours away, 8:05:35:218 AM.  The fix, however, is easy -- replace %H (hours of a 24-hour clock) with %I (hours of a 12-hour clock).

 

Bob Schor

0 Kudos
Message 9 of 10
(4,587 Views)

@Bob_Schor wrote:

Not to be too picky, but if the initial time is 8:05:35.218 PM, Crossrulz's returned time is twelve hours away, 8:05:35:218 AM.  The fix, however, is easy -- replace %H (hours of a 24-hour clock) with %I (hours of a 12-hour clock).

 

Bob Schor


Yeah, my bad.  The %p is actually ignored when using the 24 hour...hour.  Using the 12 hour format with the %I fixes it.  Nice catch.


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
0 Kudos
Message 10 of 10
(4,582 Views)