There are two primary methods to convert data from string to timestamp datatype:
Use the Scan from String VI
- On your LabVIEW VI block diagram, right-click to open the Functions Palette and navigate to Programming >> String >> Scan from String.
- Configure that Scan from String VI
- Right-click the Scan from String VI and select Edit Scan String from the dropdown menu.
- From the Selected operation menu, select Scan time stamp.
- Customize the string format using the Corresponding scan string textbox. Use the Time Stamp Format Codes as guidance to match the format of your string data.
- The example shown in this article uses the following format string: %<%I:%M:%S%3u %p%m/%d/%Y>T
- An example input string that works with the example shown in the article is: 4:43:25.628 pm 3/11/2024
- Note: If you leave the format string as
%T
, LabVIEW will guess based on commonly used formats.
- Select OK. Notice that a string constant matching the configuration set in the previous set is automatically wired to the format string input.
- Wire in your string data/type data into the input string.
- Right-click the output 1 node and select Create Indicator.
Use NumText.Text property of a Time Stamp indicator
- Add a Time Stamp Indicator to your VIs front panel using quick drop.
- On the block diagram, right-click the timestamp indicator icon and select Create >> Property Node >> Numreic Text >> Text to create a
NumText.Text
property node. - Right-click the Property Node and select Change All to Write.
- Right-click the Time Stamp indicator and select Properties.
- Navigate to the Display Format tab to customize the time and date output format, then select OK.