07-29-2009 01:17 AM
I have a requirement to send a date in nanoseconds since Jan 1, 0001, which seems to be the standard output of the DateTime.Now.Ticks .NET property. Since the conversion appears to get a little confusing back in 1752, I was thinking it would be best to just use the .NET feature (which is probably what is being used ont he other end anyway). But I cannot for the life of me figure out how to do this in LabVIEW.
If anyone can provide an example or gude me as to where it is hiding in the .NET list, I would appreciate it. If you have other suggestion, I am open to those as well.
Thanks,
Matthew
Solved! Go to Solution.
07-29-2009 03:55 AM - edited 07-29-2009 03:56 AM
Mathew,
I do not have very much experience with .NET, but managed to cobble together the VI which I attach. It returns the current time using the DateTime object.
For some reason I cannot get the Ticks method to work, but this may help you get started.
07-29-2009 10:01 AM
The problem is that the LabVIEW <-> .NET interface automatically converts DateTime.Now to a LabVIEW timestamp datatype, even though it's a .NET DateTime class. This is convenient if you're on the LabVIEW side, but useless if you need to process it further in .NET. Thus, you need to convert it back into a DateTime class.
See attached.
07-29-2009 11:34 AM
Thank you to both for the help. This is exactly what I needed. I was of course looking in the wrong place for the class, which didn't help myself.
NRP, the Now function doesn't set the value of the object, which is why Ticks didn't work, as the value of the object was still 0.
07-30-2009 03:45 AM
Wow! I clearly know less about .NET than I thought. I would *never* have guessed to typecast the time to a reference to get the Ticks data!
Thanks
07-30-2009 10:07 AM
nrp wrote:Wow! I clearly know less about .NET than I thought. I would *never* have guessed to typecast the time to a reference to get the Ticks data!
Thanks
I thought the same when I saw the solution. Boy is that NOT intuitive to do!
Rolf Kalbermatter
07-30-2009 10:40 AM
rolfk wrote:
I thought the same when I saw the solution. Boy is that NOT intuitive to do!
Unfortunately, that can be said about a LOT of .NET.
I still have to resort to the documentation whenever I have to create delegates.
08-13-2009 10:02 AM