LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string to timestamp

Solved!
Go to solution

I want to store calibration dates in a file so they can be checked to the current date and notify the user if any of the equipment is out of calibration.

 

What would be the easiest way to accomplish this?

 

Using scan fomr string I have been able to change the date string (MM/DD/YY) to numbers, but how do I turn them into a timestamp?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 1 of 23
(21,975 Views)
Solution
Accepted by topic author RTSLVU

Look here (if you have hours, minutes, and seconds along with a date):

 

http://digital.ni.com/public.nsf/allkb/95D386A68269A53A86257082001DAED0

0 Kudos
Message 2 of 23
(21,966 Views)

Check out the documentation on the Format DateTime String function. You can format a string to and from a timestamp datatype using %<>T or %<>t

 

Eric, that cluster manipulation is overkill just to go from string to timestamp and back.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 3 of 23
(21,964 Views)

I'd really recommend you use the ISO standard for time.  You can use the Scan From String, and Format Into String to go to and from a timestamp.

 

https://lavag.org/topic/15034-timestamp-support-for-format-into-string-scan-variant-from-string-stri...

Message 4 of 23
(21,957 Views)

From Hooovahh's link, this is what you want:

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 23
(21,947 Views)
James - I've always used that function to do conversions (only because I didn't know better). I learned something today, plus it's probably WAY faster.
0 Kudos
Message 6 of 23
(21,937 Views)

@Eric1977 wrote:

Look here (if you have hours, minutes, and seconds along with a date):

 

http://digital.ni.com/public.nsf/allkb/95D386A68269A53A86257082001DAED0


This seems like a simpler solution.

 

Cal.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 23
(21,894 Views)

It's not a simpler solution... It may be an easier solution to understand because it breaks everything down in to a cluster of info, but the overhead (and space) taken up by that is much larger. You should really get comfortable with string formatting and conversion using the single string scan VIs from the other posts above.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 23
(21,885 Views)

 

 


@James.M wrote:

It's not a simpler solution... It may be an easier solution to understand because it breaks everything down in to a cluster of info, but the overhead (and space) taken up by that is much larger. You should really get comfortable with string formatting and conversion using the single string scan VIs from the other posts above.


I don't understand the other proposed sultions at all and can not figure out how to apply them to my situation.

 

I can not even figure out how to get your snippet into a block diagram without it just being a picture.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 23
(21,861 Views)

It literally is two primatives and a string constant.  Here is the VI.

0 Kudos
Message 10 of 23
(21,809 Views)