LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filetime

Hi,

 

I read out a time value from a device in form of an array of having 8 bytes:

 

(104, 250, 124, 127, 195, 250, 212, 1)

 

I would like to convert this to a human readable format.

In Delphi there is a command converting filetime to systemtime, and I am wondering how can I do it in LabVIEW.

Probably sth similar to this one:

https://stackoverflow.com/questions/34630023/how-to-convert-8-byte-array-acquired-from-cfgmgr32-dll-...

 

Thanks,

MOJO

0 Kudos
Message 1 of 6
(3,545 Views)

Your question has no answer.  8 u8 numbers can be manipulated many ways to represent a time, but if you don't know the "rules" (how the originator meant them to be used), it's pretty hopeless.

 

Two representations:

  • Windows File Creation:  A 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC).
  • LabVIEW TimeStamp:  An I64-bit value representing the number of seconds since 12:00 A.M., January 1, 1904, UTC, and a U64-bit value representing fractional seconds, with a tick being 1/2^64 of a second.

If you know what your bytes represent (and the correct byte order), you can express it as a Date and Time.

 

Bob Schor

0 Kudos
Message 2 of 6
(3,500 Views)

Thank you for your answer.

It is your first mentioned option, the windows file creation. A 64bit value in 100 nanoseconds from 1601.

 

I figured out the solution on my own. I hope it will help all of you.

The value comes out of a sensor/device of Inficon company.

 

This is how I do the conversion to a timestamp:

 

i) 8 x 8byte array to hexadecimal string

(104, 250, 124, 127, 195, 250, 212, 1) -> (68, FA, 7C, 7F, C3, FA, D4, 1)

ii) turn values (width 2!)

(68, FA, 7C, 7F, C3, FA, D4, 1) -> (01, D4, FA, C3, 7F, 7C, FA, 68)

iii) use hex string to number to get the filetime

(01, D4, FA, C3, 7F, 7C, FA, 68) -> 132006006665050728

 

Filetime to seconds from 1904 for further LabVIEW processing is described by TBD, see his post here:

https://forums.ni.com/t5/LabVIEW/convert-64bit-UTC-time-since-1-jan-1601-to-current-time-labview

 

Regards,

MOJO

0 Kudos
Message 3 of 6
(3,475 Views)

@MOJO_FZJ wrote:

Thank you for your answer.

It is your first mentioned option, the windows file creation. A 64bit value in 100 nanoseconds from 1601.

 

I figured out the solution on my own. I hope it will help all of you.

The value comes out of a sensor/device of Inficon company.

 

This is how I do the conversion to a timestamp:

 

i) 8 x 8byte array to hexadecimal string

(104, 250, 124, 127, 195, 250, 212, 1) -> (68, FA, 7C, 7F, C3, FA, D4, 1)

ii) turn values (width 2!)

(68, FA, 7C, 7F, C3, FA, D4, 1) -> (01, D4, FA, C3, 7F, 7C, FA, 68)

iii) use hex string to number to get the filetime

(01, D4, FA, C3, 7F, 7C, FA, 68) -> 132006006665050728

 

Filetime to seconds from 1904 for further LabVIEW processing is described by TBD, see his post here:

https://forums.ni.com/t5/LabVIEW/convert-64bit-UTC-time-since-1-jan-1601-to-current-time-labview

 

Regards,

MOJO


Good find, but no need to convert to hex string.  Just use Reverse 1D Array, and Byte Array to String, then use the functions from that link

0 Kudos
Message 4 of 6
(3,462 Views)

Hi,

 

no need to reverse that array:

check.png(UnflattenFromString…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(3,438 Views)

Great, thank you GerdW! KUDO!

 

UnflattenFrom Stringis a bit magic to me, but your code is much more elegant than my solution with number/string conversion functions.

0 Kudos
Message 6 of 6
(3,431 Views)