06-01-2015 07:46 AM
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
06-01-2015 08:21 AM
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.
06-01-2015 08:31 AM
Hi crossrulz,
I tired as you suggested but still did the get the solution.
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.
06-01-2015 08:35 AM - edited 06-01-2015 08:36 AM
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.
06-01-2015 08:38 AM
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
06-01-2015 08:57 AM
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
06-02-2015 05:33 AM
Hi Bob,
Did the changes and now it gives the milliseconds.
Attached the solution png.
Thanks to all
06-02-2015 06:59 AM - edited 06-02-2015 07:01 AM
You do realize you could have just used a single Scan From String to get the timestamp, right?
06-02-2015 08:12 AM
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
06-02-2015 08:29 AM
@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.