LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Date/Time <---> String

Hallo,

There's the Format Date/Time string function to convert from the timestamp
datatype to a string.

Now I'm searching for the reverse way to convert from that string back to
timestamp format again. Please tell me the function or a way I can do this
with as less effort as possible!

Thank you very much

Oliver Friedrich
0 Kudos
Message 1 of 19
(6,054 Views)
Hallo,

I would do that... 😉





Message Edité par TiTou le 03-16-200604:26 PM


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Download All
Message 2 of 19
(6,035 Views)
What you're looking for is a vi.lib VI which for some reason doesn't exist. Here is a version I started once and never got around to really finishing. You should make a product suggestion to let NI know this is needed by going to the Product Suggestion Center.

___________________
Try to take over the world!
Message 3 of 19
(6,024 Views)
Wow... well done tst, that's a lot more professional than my snipet !

I'll add it to my vi box if you don't mind Smiley Wink , thanks !

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 19
(6,018 Views)
I don't mind, but you should keep in mind that it's not really tested and fully thought out and as a result may still have some bugs. I originally wrote it because I thought I would need it for a specific project and that I would use it many times in other places. In actuality, the only times I used it so for were not in work projects, so I never had the chance to finalize it (see for instance the completely arbitrary time limit for %Y between 1960 and 2099). I believe that as long as you use strings formatted properly it should work, but I'm not sure what will happen with bad strings. I think it should probably throw an error, but I didn't get around to examining it.

___________________
Try to take over the world!
0 Kudos
Message 5 of 19
(6,012 Views)
Thank you for thr warning.

After looking at the code I tried a "monkey test" putting silly dates.

For some reason the "date/time to seconds" :
 - works fine until 19/01/2038...
 - from 20/01/2038 to 06/02/2040 gives this :00:00:00.000 DD.MM.YYYY
 - after 07/02/2040 seems to start back from : 17:31:44.000 01.01.1904




I think the "seconds" can lead to an explanation...

Message Edité par TiTou le 03-16-200605:30 PM

Message Edité par TiTou le 03-16-200605:33 PM


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 19
(6,008 Views)
That is just the limit of the LV timestamp. I forgot it ends at 2038. The 8 representation now allows having dates from 1600 to 3000.

___________________
Try to take over the world!
0 Kudos
Message 7 of 19
(5,995 Views)
The internal limit of the LV timestamp is actually around 58 billion years from its epoch, midnight, January 1, 1904 GMT.  It is the number of seconds since (or before) the epoch expressed as a 128 bit fixed point number with 64 bits as the integer and 64 bits as the fraction (thus the ~58 billion years).  The limitation is in the format routine only, and only exists because the previous timestamp format (a simple double) could not go past 2038.  It has not been fixed because it is an uncommon problem (which will become more common as time goes by - it will get fixed).  You can directly manipulate the timestamp yourself by typecasting it into a cluster of two 64bit integers or four 32 bit integers (depending on your LabVIEW version).  Remember that it is a signed number.  You can find examples of this buried in vi.lib at <LabVIEW>\vi.lib\waveform\TSOps.llb.

If you need more information, let us know.
Message 8 of 19
(5,972 Views)

Actually, if I'm reading my calculator correctly, and allowing for it being a signed number, shouldn't that be about 275 billion years in each direction (and I realize I may be unnecessarily splitting hairs)? Anyway, I understood that this was already changed in 8, so that should be better.

And just to restate the point of the thread - we want a vi.lib String to Timestamp function!


___________________
Try to take over the world!
0 Kudos
Message 9 of 19
(5,965 Views)
Maybe the simplest method is shown in the attached VI. Using the NumText.Text property, the formatted Date&Time string is entered in a timestamp control as if the user typed it. This timestamp control is previously set to the same format as the Time&Date string input.

That is simple but I don't like this kind of code because it may fail if the application is built and the FP stripped. It is also very slow because it runs in the user interface thread. Absolutely not convenient to convert hundreds of thousand timestamp. Anyway it shows that LabVIEW has already all the builtin functions to code a Time&Date string converter.

Message Edité par JeanPierre le 03-17-2006 09:19 AM



LabVIEW, C'est LabVIEW

Message 10 of 19
(5,963 Views)