« Previous Next »

Thread: converting lastLogon to a timestamp??

Last post 01-23-2007 9:02 AM by LogParser User : huberse. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 06-30-2006, 4:10 PM

    converting lastLogon to a timestamp??

    My query:

    C:\Program Files\Log Parser 2.2>logparser "SELECT displayName,cn,description,mail,whenCreated,whenCh
    anged,lastLogon FROM LDAP://domain.com/DC=domain,DC=com" -i:ADS -oATAGRID -objClass:User

    returns something like 127934555069865000.00 for lastLogon.

    Tried

    C:\Program Files\Log Parser 2.2>logparser "SELECT displayName,cn,description,mail,whenCreated,whenCh
    anged,TO_TIMESTAMP( lastLogon, 'yyyy-MM-dd hh:mm:ss') AS LastLogon FROM LDAP://domain.com/DC=domain,DC=com" -i:ADS -oATAGRID -objClass:User

    but get this

    Error: Syntax Error: <timestamp>: missing timestamp

     

    Thanks for any help

  • 06-30-2006, 4:36 PM In reply to

    RE: converting lastLogon to a timestamp??

    I'm not familiar with the input format you are using. What is the raw format of the lastLogon field? Is it a date string or an int or what?
  • 06-30-2006, 4:40 PM In reply to

    RE: converting lastLogon to a timestamp??

    it's a timestamp in the Active Directory for the last time the user logged on to the domain.  It seems to be in seconds or something.  In adsiedit, the attribute is listed with a syntax description of Large Interger/Interval

  • 07-02-2006, 10:28 AM In reply to

    RE: converting lastLogon to a timestamp??

    Search the forums for the term epoch. You'll find a post from me with a reply from Gabriel about the best way to handle that type of timestamp.
  • 01-23-2007, 9:02 AM In reply to

    RE: converting lastLogon to a timestamp??

    had to try also a little time .... but here's the Result that works.

    AD counts in 100 nanoseconds from 1. Jan 1601 ?!? weird somehow

    SELECT TO_TIMESTAMP(ADD(DIV(TO_REAL(LastLogon), 10000000.0), TO_REAL(TIMESTAMP('1601','yyyy')))) AS [LastLogon]


    best regards Serge
Page 1 of 1 (5 items)
Microsoft Communities