BrokenWire Posted May 22, 2007 Report Share Posted May 22, 2007 QUOTE(yen @ May 15 2005, 07:40 AM) Often people read text data which includes a date\time.Currently, there is no inherent function in LV for converting a time string to a timestamp. The suggestion is to have a VI, basically a reverse VI to Format Date\Time String, which will convert a date\time string to a LV timestamp based on a LV format string. I was having the same wish for a function when I decided to do this for myself...that is convert a string to a LV Timestamp. What I did was prep the string data using the string commands so that it appears in the mm/dd/yyyy format. Create a timestamp control then create a property node for the NumText.Text (Property Node > Numeric Text > Text) and wire the date string to the node. Now when you pass the value from the control it will be formatted as a timestamp. I hope this helps Quote Link to comment
Yair Posted May 23, 2007 Report Share Posted May 23, 2007 The problem with that method is that you're relying on a control and on workarounds. A better approach is to convert the various string elements to numbers, build them into a time rec cluster and convert that cluster to a timestamp, so that you preserve data flow. There have been some implementations for this posted to the web. With the addition mentioned here of using Scan From String, it should probably be simpler. Quote Link to comment
Bluetin Posted August 9, 2007 Report Share Posted August 9, 2007 QUOTE(yen @ May 22 2007, 04:32 AM) The problem with that method is that you're relying on a control and on workarounds. A better approach is to convert the various string elements to numbers, build them into a time rec cluster and convert that cluster to a timestamp, so that you preserve data flow. There have been some implementations for this posted to the web. With the addition mentioned here of using Scan From String, it should probably be simpler. Yen, I have used the cluster method as well as BrokenWire's property node method. Both methods work fine. But you are very wrong that the cluster method is simpler. I haven't figured out how to post an image to this forum yet, so I put an url to a gif of a block diagram showing how much simpler it is to put a time string or a date-time string into a timestamp control. Thanks BrokenWire. http://forums.lavag.org/index.php?automodule=gallery&req=si&img=1010' target="_blank">http://forums.lavag.org/index.php?automodu...si&img=1010 Quote Link to comment
Yair Posted August 11, 2007 Report Share Posted August 11, 2007 I didn't say the cluster method is simpler. I said the Scan From String method is simpler. To embed a picture, you need to upload it (there's an attachments section under the post window) and in the Manage Current Attachments ring you can select to embed it in the post. Quote Link to comment
Ton Plomp Posted August 11, 2007 Report Share Posted August 11, 2007 Bluetin your solution relies on the fact that your computer time settings don't change. Yen's as well but are a little bit more error proof. Ton Quote Link to comment
Bluetin Posted August 11, 2007 Report Share Posted August 11, 2007 "Bluetin your solution relies on the fact that your computer time settings don't change. Yen's as well but are a little bit more error proof." How do you figure that?! I am getting a date time STRING as data from any source in this case a datalogger. When I put the string into a timestamp I can easily subtract 2 timestamps to get the time elapsed. The point was how to put a string into a timestamp. Parsing a string into a cluster and then converting the cluster to a timestamp also works as Yen has said. But he blew off Brokenwire's suggestion as not simple when it is vastly simpler. QUOTE(yen @ Aug 9 2007, 04:29 PM) I didn't say the cluster method is simpler. I said the Scan From String method is simpler.To embed a picture, you need to upload it (there's an attachments section under the post window) and in the Manage Current Attachments ring you can select to embed it in the post. Thanks for the hint on pictures. The scan Time from string method is great if you have version 8.X The property node method works in 7.X It probably also works in 6.X but I don't have any old version 6's and I don't really want to get out my old version 5.1 just to see. QUOTE(BrokenWire @ May 21 2007, 11:05 AM) I was having the same wish for a function when I decided to do this for myself...that is convert a string to a LV Timestamp. What I did was prep the string data using the string commands so that it appears in the mm/dd/yyyy format. Create a timestamp control then create a property node for the NumText.Text (Property Node > Numeric Text > Text) and wire the date string to the node. Now when you pass the value from the control it will be formatted as a timestamp. I hope this helps By the way BrokenWire you don't need to reformat the string, you need to change the settings of the TimeStamp to match the string. http://forums.lavag.org/index.php?act=attach&type=post&id=6606 http://forums.lavag.org/index.php?act=attach&type=post&id=6604 http://forums.lavag.org/index.php?act=attach&type=post&id=6605 Quote Link to comment
Yair Posted August 12, 2007 Report Share Posted August 12, 2007 Ton, I agree that this should not rely on the PC's settings. Since you're reading a time string, you should already know how that string is formatted and use the specific format string. Bluetin, I said that the Scan from String method is simpler than the cluster method (a basic example of which is shown here), not the control method. It's not any simpler than the control method, since it's basically the same, but I don't like the control method because you have to rely on a control and you probably have to change the control's format to get it to work properly in every case. It works, but seems like a dirty hack. I use LV 7.0 myself, so I don't have the Scan from String either, but I would prefer a proper VI for this over the control method. Quote Link to comment
Bluetin Posted August 12, 2007 Report Share Posted August 12, 2007 QUOTE(yen @ Aug 10 2007, 05:33 PM) Ton, I agree that this should not rely on the PC's settings. Since you're reading a time string, you should already know how that string is formatted and use the specific format string.Bluetin, I said that the Scan from String method is simpler than the cluster method (a basic example of which is shown http://forums.ni.com/ni/board/message?board.id=170&message.id=174014#M174014' target="_blank">here), not the control method. It's not any simpler than the control method, since it's basically the same, but I don't like the control method because you have to rely on a control and you probably have to change the control's format to get it to work properly in every case. It works, but seems like a dirty hack. I use LV 7.0 myself, so I don't have the Scan from String either, but I would prefer a proper VI for this over the control method. As would I, for the same reason Quote Link to comment
robijn Posted August 28, 2007 Report Share Posted August 28, 2007 Hi, i have some time scanning / timezone conversion VI's available on my site. They still use LV6 style DBL's so are not really up to date, but they worked splendidly there. I have a temporary version laying around here that has the big TS's and is probably OK but I have not had time to release it. If anyone wants to try that TS version let me know. http://robijn.net/labview/ Joris Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.