Automation Master
Automation Master

Reading AD timestamps / time values

The problem

So dealing with Active Directory and timestamps, not fun. If you go into the Attribute Editor in AD and look at a timestamp on a use, accountExpires for example, it's a huge 64-bit integer. How does that represent a time? More importantly, how do you get Nintex to turn it into a DateTime variable?


The Background

AD timestamps (aka WinTime, aka FileTime) is the number of 100-nanosecond intervals since 01/01/1601 @ 00:00.


You can think of it as how many 0.0000001 seconds have past since 01/01/1601.


One think to watch out for is what happens when the user is set not to expire? This sets the accountExpires attribute to either "0" or "9223372036854775807" which is hex for 0x7FFFFFFFFFFFFFFF. Best not to think about why Microsoft chose that, I've lost a few brain-cells trying to figure it out.


Another hurdle to watch out for is that the earliest time that Nintex can deal with is 01/01/1900, so it can't go all the way back to the year 1601 to do the math. To get around that, we'll be applying an offset to bring it up to 01/01/1900.


The Solution

Ok, so you've retrieved the timestamp from an AD query, but it's just a large number as a string. Below is an example workflow you can use to turn it into a DateTime variable.

Timestamp Nintex 1.jpg


Here is the Calculate Date function. Basically, take 01/01/1900 @ midnight and add on the timestamp in minutes.

Timestamp Nintex 2.jpg


And that's it!

That big, nasty timestamp is now in a nice, friendly DateTime variable that we can do things with and checks against. It'll also determine if an account is set to expire or not.


I interface with AD in most of my workflows so I turned this into a User Defined Action, making things nice and easy. I like nice and easy.


Attached is a copy of the workflow.

Thanks for the tips David

No problem, glad I could help

This document was generated from the following discussion: Reading AD timestamps / time values

1 Reply
Automation Master
Automation Master

Re: Reading AD timestamps / time values

I didn't write this. I converted a well written post into a document and now I am asking on how to fix this to be back to @towerofpower256's !