STCK to DateTime type conversion

  • Thread starter Thread starter Daniel Stoever
  • Start date Start date
D

Daniel Stoever

I have a client program that talks to an IBM mainframe and recieves
64bit unsigned integers(STCK) that represent date-time values. I need to
convert these to native DateTime format for use in my c# code. There
appears to be a convert function that takes a long parameter and returns
a DateTime but not a ulong. Anyone have or know of any conversion
routines available for this purpose. If not I'll have to write my own.
Thanks.
 
Daniel,

I would use the BitConverter class, getting the bytes, and then passing
the bytes back, calling the ToInt64 method. Once you have that, you can
pass the long to the appropriate method on the DateTime class to convert the
long into a DateTime.

Hope this helps.
 
...
I would use the BitConverter class, getting the bytes,
and then passing the bytes back, calling the ToInt64
method. Once you have that, you can pass the long to
the appropriate method on the DateTime class to convert
the long into a DateTime.

I don't think that would be necessary, or enough for that matter...

If the OP already have a .NET-client talking to the IBM mainframe, the
actual "transportation" of the ulong would be the least problem.

The ToDateTime in Convert that takes a long seems to be "not implemented
yet"...

And, the constructor in the DateTime struct that takes a long is supposed to
take the number of "ticks" (100-nanoseconds since 0001-01-01 12:00 AM),
which probably is *not* what an STCK looks like...

In one place I've seen an STCK defined as the number of milliseconds since
1900-01-01 something...

I've also seen another definition of STCK as the first 32 bits representing
the Date, while the latter 32 bits representing a fraction of a day, hence
the time part...

So, if you look up what the STCK really looks like on your IBM, and share
that with us, we could possibly come up with some simple way to convert it
to the correct DateTime.

just my 2c

// Bjorn A
 
Back
Top