LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I turn the get date/time string function into a 1D array?

I have a build array function which contain many 1D elements, now I wanted to add the date and time stamp at the first and second element in the build array function but I don't know how to turn the date and time string into a 1D array to feed it into my build array function. I tried to use the spreedsheat string to array function but it doesn't work.
0 Kudos
Message 1 of 6
(3,913 Views)
If your array is 1D, just stretch your Build Array function at the top to add two inputs (or right-click on the function and select Add Input twice, but then you may need to rewire existing inputs). Then individually wire the string outputs from Get Date/Time String to the top two inputs. E.g., if you want date to be the first element, wire that string to the top input and wire the time string to the second input. Build Array can automatically combine single elements with other single elements or with an existing array. You don't need to "turn the date and time string into a 1D array" to add them to your existing array. Just use Build Array to add them as inputs.
0 Kudos
Message 2 of 6
(3,913 Views)
One other thing is that the 1D array has to be a string array. You can't have an array of different data types.
0 Kudos
Message 3 of 6
(3,913 Views)
That is actually my problem, the data type of the 2 are different, my 1D array is numeric which is different from the data type on the date and time string.
0 Kudos
Message 4 of 6
(3,913 Views)
Instead of saving the date and time as a string, use the Get Date/Time in Seconds function, which returns the number of seconds since 12:00 AM, January 1, 1904 Universal Time. Wire that numeric output to the top input in your Build Array function for your numeric array. Whenever you want to read the date and time, use the Index Array function to read array element 0 and wire that number to the seconds input of the Get Date/Time String function. If the seconds input is unwired, Get Date/Time String returns the current date and time, but if seconds is wired, it will convert those seconds (since 12:00 AM, January 1, 1904 Universal Time) to date and time strings for your time zone.
0 Kudos
Message 5 of 6
(3,913 Views)
Al's comment about storing the date/time as a numeric is a good idea. However, just to give you some more ideas, you could also convert the numbers to strings and then have a string array or you could use a cluster instead of an array. Clusters allow mixing of datatypes. Use whatever best fits your requirements.
0 Kudos
Message 6 of 6
(3,913 Views)